-
Notifications
You must be signed in to change notification settings - Fork 976
Closed
Description
Unexpectedly thrown SyntaxError from acorn-loose parse when using invalid numeric separators with ecmaVersion 2021 and above:
> looseParse("0_", { ecmaVersion: 2021 })
Uncaught:
[SyntaxError: Numeric separator is not allowed in legacy octal numeric literals (1:1)
] {
pos: 1,
loc: Position { line: 1, column: 1 },
raisedAt: 1
}
Does not throw with ecmaVersion 2020 and below:
> looseParse("0_", { ecmaVersion: 2020 })
Node {
type: 'Program',
start: 0,
end: 2,
body: [ Node { type: 'EmptyStatement', start: 2, end: 2 } ],
sourceType: 'script'
}
Note that the same happens with input 1_
, but the error is different (“Numeric separator is not allowed at the last of digits”).
Errors are marked as recoverable in the source code:
Lines 466 to 468 in 82233bf
if (isLegacyOctalNumericLiteral) this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals") | |
if (lastCode === 95) this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore") | |
if (i === 0) this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits") |
Metadata
Metadata
Assignees
Labels
No labels