Is '\0' followed by a decimal digit in string allowed in ECMA-262 strict mode?

前端 未结 1 1026
慢半拍i
慢半拍i 2021-01-21 08:28

According to the ECMA-262 specification (6th edition) in strict mode in single or double quoted strings after \'\\\' it is possible to have EscapeSequence or LineTerminatorSeque

相关标签:
1条回答
  • 2021-01-21 09:18

    "0 [lookahead ∉ DecimalDigit]" sounds pretty unambiguous to me: no decimal digit is allowed after \0.

    Which means the fact that V8 allows "\08" and "\09" in strict mode is a bug. Would you please file a bug at https://bugs.chromium.org/p/v8/?

    Interestingly, test262 does not seem to cover this case at all...

    Somewhat related: all browsers accept "\8" and "\9" in strict mode, which according to the spec should throw a SyntaxError. There's a thread on esdiscuss.org indicating that this spec violation is (or at least used to be) required for web compatibility though: when existing websites depend on non-spec-compliant behavior, then browsers usually can't just update their behavior to be spec-compliant, because doing so would break such websites, and having websites work correctly is more important for users (and, hence, browser developers) than being spec-compliant.

    0 讨论(0)
提交回复
热议问题