Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[parser] Disallow numeric separators in legacy octal like integers #10493

Merged
merged 4 commits into from Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/babel-parser/src/tokenizer/index.js
Expand Up @@ -1035,8 +1035,11 @@ export default class Tokenizer extends LocationParser {
next = this.input.charCodeAt(this.state.pos);
}

// disallow numeric separators in non octal decimals
if (this.hasPlugin("numericSeparator") && isNonOctalDecimalInt) {
// disallow numeric separators in non octal decimals and legacy octal likes
if (
(this.hasPlugin("numericSeparator") && isNonOctalDecimalInt) ||
(this.hasPlugin("numericSeparator") && octal)
zant marked this conversation as resolved.
Show resolved Hide resolved
) {
const underscorePos = this.input
.slice(start, this.state.pos)
.indexOf("_");
Expand Down
@@ -0,0 +1 @@
00_0
zant marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1 @@
{ "throws": "Numeric separator can not be used after leading 0 (1:2)" }
6 changes: 0 additions & 6 deletions scripts/tests/test262/test262_whitelist.txt
Expand Up @@ -104,12 +104,6 @@ language/expressions/object/method-definition/private-name-early-error-gen-insid
language/expressions/object/method-definition/private-name-early-error-gen-inside-class.js(strict mode)
language/expressions/object/method-definition/private-name-early-error-method-inside-class.js(default)
language/expressions/object/method-definition/private-name-early-error-method-inside-class.js(strict mode)
language/literals/numeric/numeric-separators/numeric-separator-literal-lol-00-err.js(default)
language/literals/numeric/numeric-separators/numeric-separator-literal-lol-01-err.js(default)
language/literals/numeric/numeric-separators/numeric-separator-literal-lol-07-err.js(default)
language/literals/numeric/numeric-separators/numeric-separator-literal-lol-0_0-err.js(default)
language/literals/numeric/numeric-separators/numeric-separator-literal-lol-0_1-err.js(default)
language/literals/numeric/numeric-separators/numeric-separator-literal-lol-0_7-err.js(default)
language/module-code/privatename-not-valid-earlyerr-module-1.js(default)
language/module-code/privatename-not-valid-earlyerr-module-1.js(strict mode)
language/module-code/privatename-not-valid-earlyerr-module-2.js(default)
Expand Down