LiteralPropertyName should allow BigIntLiteral (#10955)
* fix: property name should allow BigIntLiteral * test: add non decimal test case * add bigintIndex to whitelist
This commit is contained in:
parent
3fa37d2da3
commit
8fd532db39
@ -1790,7 +1790,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
this.state.inPropertyName = true;
|
this.state.inPropertyName = true;
|
||||||
// We check if it's valid for it to be a private name when we push it.
|
// We check if it's valid for it to be a private name when we push it.
|
||||||
(prop: $FlowFixMe).key =
|
(prop: $FlowFixMe).key =
|
||||||
this.match(tt.num) || this.match(tt.string)
|
this.match(tt.num) || this.match(tt.string) || this.match(tt.bigint)
|
||||||
? this.parseExprAtom()
|
? this.parseExprAtom()
|
||||||
: this.parseMaybePrivateName();
|
: this.parseMaybePrivateName();
|
||||||
|
|
||||||
|
|||||||
1
packages/babel-parser/test/fixtures/experimental/bigint/decimal-as-property-name/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/experimental/bigint/decimal-as-property-name/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
({ 0n: 0 });
|
||||||
129
packages/babel-parser/test/fixtures/experimental/bigint/decimal-as-property-name/output.json
vendored
Normal file
129
packages/babel-parser/test/fixtures/experimental/bigint/decimal-as-property-name/output.json
vendored
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"start": 1,
|
||||||
|
"end": 10,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 1
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"type": "ObjectProperty",
|
||||||
|
"start": 3,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"method": false,
|
||||||
|
"key": {
|
||||||
|
"type": "BigIntLiteral",
|
||||||
|
"start": 3,
|
||||||
|
"end": 5,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "0",
|
||||||
|
"raw": "0n"
|
||||||
|
},
|
||||||
|
"value": "0"
|
||||||
|
},
|
||||||
|
"computed": false,
|
||||||
|
"shorthand": false,
|
||||||
|
"value": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start": 7,
|
||||||
|
"end": 8,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 0,
|
||||||
|
"raw": "0"
|
||||||
|
},
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra": {
|
||||||
|
"parenthesized": true,
|
||||||
|
"parenStart": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/babel-parser/test/fixtures/experimental/bigint/hex-as-property-name/input.js
vendored
Normal file
1
packages/babel-parser/test/fixtures/experimental/bigint/hex-as-property-name/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
({ 0xbeefban: 0 });
|
||||||
129
packages/babel-parser/test/fixtures/experimental/bigint/hex-as-property-name/output.json
vendored
Normal file
129
packages/babel-parser/test/fixtures/experimental/bigint/hex-as-property-name/output.json
vendored
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
{
|
||||||
|
"type": "File",
|
||||||
|
"start": 0,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"program": {
|
||||||
|
"type": "Program",
|
||||||
|
"start": 0,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sourceType": "script",
|
||||||
|
"interpreter": null,
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"start": 0,
|
||||||
|
"end": 19,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 0
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 19
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"expression": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"start": 1,
|
||||||
|
"end": 17,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 1
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"type": "ObjectProperty",
|
||||||
|
"start": 3,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"method": false,
|
||||||
|
"key": {
|
||||||
|
"type": "BigIntLiteral",
|
||||||
|
"start": 3,
|
||||||
|
"end": 12,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 3
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "0xbeefba",
|
||||||
|
"raw": "0xbeefban"
|
||||||
|
},
|
||||||
|
"value": "0xbeefba"
|
||||||
|
},
|
||||||
|
"computed": false,
|
||||||
|
"shorthand": false,
|
||||||
|
"value": {
|
||||||
|
"type": "NumericLiteral",
|
||||||
|
"start": 14,
|
||||||
|
"end": 15,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": 0,
|
||||||
|
"raw": "0"
|
||||||
|
},
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra": {
|
||||||
|
"parenthesized": true,
|
||||||
|
"parenStart": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directives": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -61,6 +61,7 @@ augmentedTypesVar.ts
|
|||||||
awaitInNonAsyncFunction.ts
|
awaitInNonAsyncFunction.ts
|
||||||
awaitLiteralValues.ts
|
awaitLiteralValues.ts
|
||||||
bigIntWithTargetES3.ts
|
bigIntWithTargetES3.ts
|
||||||
|
bigintIndex.ts
|
||||||
bigintWithLib.ts
|
bigintWithLib.ts
|
||||||
breakNotInIterationOrSwitchStatement1.ts
|
breakNotInIterationOrSwitchStatement1.ts
|
||||||
breakNotInIterationOrSwitchStatement2.ts
|
breakNotInIterationOrSwitchStatement2.ts
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user