1

According to the 6th edition of the ECMA-262 specification in strict mode in single or double quoted strings after '\' it is possible to have EscapeSequence or LineTerminatorSequence and EscapeSequence must be one of the following: CharacterEscapeSequence, 0 [lookahead ∉ DecimalDigit], HexEscapeSequence, UnicodeEscapeSequence (see 11.8.4). CharacterEscapeSequence can be either a SingleEscapeCharacter or a NonEscapeCharacter, which can't be an EscapeCharacter, whilst EscapeCharacter includes DecimalDigit.

The problem is there is no description of SV (string value) of any EscapeCharacter in 11.8.4.3 and it is only being referred to as something which is not a NonEscapeCharacter.

Does it mean that it is incorrect to have a '\' followed by the DecimalDigit? Or does omitting this in specification mean that it is up to the implementation to decide about how it must be interpreted?

I tested this on different engines and it seems that V8, SpiderMonkey, and Chakra all return SyntaxError for '\' followed by the OctalDigit with a message about octal number literals being unsupported in strict mode, and return just the code point value of the digit after the '\' for the DecimalDigits which are not OctalDigits ('\8' and '\9' result in '8' and '9' respectively).

Am I missing something in the specification? Can this behavior be considered as correct?

user4699276
  • 120
  • 1
  • 6
  • Note that you can edit your existing question. There is an edit button/link below the tags - bottom-left of the question. – cartant Jun 17 '17 at 04:09

0 Answers0