-
Notifications
You must be signed in to change notification settings - Fork 27
Numeric separators allowed in extended Unicode escape sequences? #25
Comments
Not intentional, per September 2017 TC39 meeting. |
https://tc39.github.io/ecma262/#sec-static-semantics-sv > The SV of UnicodeEscapeSequence::u{CodePoint} is the UTF16Encoding of the MV of CodePoint. And CodePoint is: CodePoint :: HexDigits (but only if MV of HexDigits ≤ 0x10FFFF) ------------------------------------------------------------- This patch explicitly defines the MV of HexDigits as: - The MV of HexDigits :: HexDigits NumericLiteralSeparator HexDigit is (the MV of HexDigits * 16) plus the MV of HexDigit. It also adds similar definitions for: DecimalDigits, BinaryDigits and OctalDigits
The solution I chose is to explicitly define the MV such that NLS has no impact on the resulting value. |
With the change, e.g. I’d have preferred to disallow it in escape sequences, following the “no real benefit there” logic in https://github.com/tc39/proposal-numeric-separator#octal-literal, but don’t feel strongly about it. What do you think, @anba? |
And the NLS spec adds:
|
To be clear, this was only one of 3 possible solutions that @leobalter and I discussed. We agreed that an explicit Static Semantics could be written as well. |
I don't have any strong opinion if we should disallow NLS in escape sequences or not. My goal is only to fetch the correct spec for what ends up as the chosen one. One feedback that might be helpful is collecting implementors PoV. It disallowing NLS in escape sequences is easier to implement, I'm all in. I'd be happy to help writing an explicit error to disallow. |
I don't feel really strongly, but my intuition was the same as @mathiasbynens 's--I don't see a strong reason to permit numeric separator in Unicode literals. It wasn't clear to me during the Stage 3 presentation that you were proposing to allow it--I misunderstood that the fix was to disallow it, and allowing numeric separators there was an accident. |
FWIW, my understanding of the presentation matched @littledan's. |
Reopening for explicit Static Semantics to produce a SyntaxError whenever |
Ping, it would be good to get clarity on this issue before integrating with the BigInt specification (or implementing and shipping). |
@littledan I believe the decision is throwing when a Num. separator appears in escape sequences. We might need to update the specs to match that. |
This seems ugly, but we could get a fix to the escape sequence by changing CodePoint to:
or:
I'm not sure if I like adding more grammar production flags. |
Confirm, these are the desired semantics. |
@leobalter I've updated the spec to include your first option. NumericLiteralSeparator is not allowed Tests to follow. |
The fix in 06b17eb LGTM. (I was surprised that CodePoints is under the template literal heading, but seems like that's what string literals, RegExps, etc cross-reference). Does MV need an update to explain what the value of CodePointDigits is, or is that considered clear from analogy with its other productions? |
The current proposal allows
"\u{10_ffff}"
. Is this intentional?The text was updated successfully, but these errors were encountered: