[parser] Better error message for missing number exponent (#12072)
* fix(babel-parser) better error message for missing number exponent after 'e' * fix(babel-parser) requested changes * msg Co-authored-by: Brian Ng <bng412@gmail.com>
This commit is contained in:
parent
f697e7995d
commit
59d97d9bca
@ -77,6 +77,8 @@ export const ErrorMessages = Object.freeze({
|
||||
InvalidLhs: "Invalid left-hand side in %0",
|
||||
InvalidLhsBinding: "Binding invalid left-hand side in %0",
|
||||
InvalidNumber: "Invalid number",
|
||||
InvalidOrMissingExponent:
|
||||
"Floating-point numbers require a valid exponent after the 'e'",
|
||||
InvalidOrUnexpectedToken: "Unexpected character '%0'",
|
||||
InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern",
|
||||
InvalidPrivateFieldResolution: "Private name #%0 is not defined",
|
||||
|
||||
@ -1149,7 +1149,9 @@ export default class Tokenizer extends ParserErrors {
|
||||
if (next === charCodes.plusSign || next === charCodes.dash) {
|
||||
++this.state.pos;
|
||||
}
|
||||
if (this.readInt(10) === null) this.raise(start, Errors.InvalidNumber);
|
||||
if (this.readInt(10) === null) {
|
||||
this.raise(start, Errors.InvalidOrMissingExponent);
|
||||
}
|
||||
isFloat = true;
|
||||
hasExponent = true;
|
||||
next = this.input.charCodeAt(this.state.pos);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":2,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":2}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid number (1:0)"
|
||||
"SyntaxError: Floating-point numbers require a valid exponent after the 'e' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid number (1:0)"
|
||||
"SyntaxError: Floating-point numbers require a valid exponent after the 'e' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid number (1:0)"
|
||||
"SyntaxError: Floating-point numbers require a valid exponent after the 'e' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":2,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":2}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid number (1:0)"
|
||||
"SyntaxError: Floating-point numbers require a valid exponent after the 'e' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid number (1:0)"
|
||||
"SyntaxError: Floating-point numbers require a valid exponent after the 'e' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"type": "File",
|
||||
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3}},
|
||||
"errors": [
|
||||
"SyntaxError: Invalid number (1:0)"
|
||||
"SyntaxError: Floating-point numbers require a valid exponent after the 'e' (1:0)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user