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

Numeric Separators in Legacy NonOctal #2090

Closed
leobalter opened this issue Jul 10, 2020 · 1 comment
Closed

Numeric Separators in Legacy NonOctal #2090

leobalter opened this issue Jul 10, 2020 · 1 comment

Comments

@leobalter
Copy link
Member

I'd love to tackle this as a follow up to the Numeric Separators proposal scheduled for Stage 4 in July 2020.

I've been working on tc39/proposal-numeric-separator#49 and while trying to fetch the matching grammar for Legacy NonOctal literals.

The problem: while I was aiming to address 08.1_1 or 08e1_0 as a Legacy NonOctal containing exponential / fractional parts where numeric separators are "allowed", I'm not sure how we would forbid these productions to allow numeric separators.

My question: should we pursue a change in the specs to forbid Numeric Separators in exponential or fractional parts of Legacy NonOctal literals. It sounds like a change would require expanding Annex B to change DecimalLiteral or create a static error for productions of DecimalIntegerLiteral . DecimalDigits_opt ExponentPart_opt and DecimalIntegerLiteral ExponentPart_opt if a numeric separator is present.

The change would also require change the current implementation of JSC, SpiderMonkey, and V8, as they allow the separators in these parts.

Related Grammar (w/ Numeric Separators)

DecimalLiteral::
  DecimalIntegerLiteral . DecimalDigits_opt ExponentPart_opt
  . DecimalDigits ExponentPart_opt
  DecimalIntegerLiteral ExponentPart_opt

DecimalDigits::
  DecimalDigit
  DecimalDigits NumericLiteralSeparator_opt DecimalDigit

// Annex B

DecimalIntegerLiteral ::
  0
  NonZeroDigit
  NonZeroDigit NumericLiteralSeparator_opt DecimalDigits
  NonOctalDecimalIntegerLiteral

NonOctalDecimalIntegerLiteral::
  0 NonOctalDigit
  LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit
  NonOctalDecimalIntegerLiteral DecimalDigit

Examples (all in non-strict mode):

➜ eshost -tse '08.11' # NonOctalDecimalIntegerLiteral . DecimalDigits
┌────────────────┬─────┐
│ ChakraCore     │ 8.11 │
│ engine262      │     │
│ Hermes         │     │
│ JavaScriptCore │     │
│ Moddable XS    │     │
│ SpiderMonkey   │     │
│ V8             │     │
└────────────────┴─────┘

➜ eshost -tse '08.1_1'
┌────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ChakraCore     │                                                                                                                        │
│                │ SyntaxError: Unexpected identifier after numeric literal                                                               │
├────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ engine262      │                                                                                                                        │
│                │ SyntaxError: Identifier directly after number (1:1899)                                                                 │
├────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Hermes         │                                                                                                                        │
│                │ SyntaxError: warning: Numeric literal starts with 0 but contains an 8 or 9 digit. Interpreting as decimal (not octal). │
├────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ JavaScriptCore │ 8.11                                                                                                                   │
│ SpiderMonkey   │                                                                                                                        │
│ V8             │                                                                                                                        │
├────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Moddable XS    │                                                                                                                        │
│                │ SyntaxError: missing ,                                                                                                 │
└────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

ExponentialPart:

➜ eshost -tse '08e10'
┌────────────────┬─────────────┐
│ ChakraCore     │ 80000000000 │
│ engine262      │             │
│ Hermes         │             │
│ JavaScriptCore │             │
│ Moddable XS    │             │
│ SpiderMonkey   │             │
│ V8             │             │
└────────────────┴─────────────┘

➜ eshost -tse '08e1_0'
┌────────────────┬──────────────────────────────────────────────────────────┐
│ ChakraCore     │                                                          │
│                │ SyntaxError: Unexpected identifier after numeric literal │
├────────────────┼──────────────────────────────────────────────────────────┤
│ engine262      │                                                          │
│                │ SyntaxError: Identifier directly after number (1:1899)   │
├────────────────┼──────────────────────────────────────────────────────────┤
│ Hermes         │                                                          │
│                │ SyntaxError: invalid numeric literal                     │
├────────────────┼──────────────────────────────────────────────────────────┤
│ JavaScriptCore │ 80000000000                                              │
│ SpiderMonkey   │                                                          │
│ V8             │                                                          │
├────────────────┼──────────────────────────────────────────────────────────┤
│ Moddable XS    │                                                          │
│                │ SyntaxError: missing ,                                   │
└────────────────┴──────────────────────────────────────────────────────────┘
@leobalter
Copy link
Member Author

At the TC39 Meeting in July 2020 we reached a conclusion this belongs to a broader matter whether NonOctals should have fractional or exponential parts disallowed.

The committee agreed to not disallow numeric separators in the fractional or exponential parts of NonOctals at this point.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant