This project is read-only.

Test 7.8.4-1-s does not correctly check whether octal escape sequences are allowed


The spec does not allow octal escape sequences within strict mode code. Test 7.8.4-1-s is designed to check this - however, I believe it fails to do so.
The code in question is this: eval(' "asterisk: \052"; "use strict";');
The eval function takes a single string and by the time it reaches that point, the escape sequences have been eliminated. Thus the octal escape sequence appears outside strict mode code (i.e. in the context of the testcase function) and thus it should be allowed.
Also debatable is whether octal escape sequences should be disallowed before the "use strict" directive is encountered. This seems like it would require the lexer to do a second pass over the code solely to resolve escape sequences.


jwalden wrote Jan 1, 2011 at 11:01 PM has a patch that also fixes this.

I proposed a fix for your suggestion (directives must not contain escapes, ergo "\052"; "use strict"; would not enter strict mode and require reparsing, or carrying seen-octal state forward when parsing the directive prologue -- SpiderMonkey does the latter because it eagerly throws away source) to the es5-discuss list, but discussion fizzled, and eventually I became fed up on waiting for a definitive yes/no as to making that change and just implemented what the spec requires in SpiderMonkey. and are the relevant bug and mailing list discussion. I'd still love it if the spec eliminated the need for this pedantry and reparsing!

wrote Feb 4, 2011 at 10:36 PM

mmaly wrote Feb 4, 2011 at 10:36 PM

We should commit the relevant part of the patch attached to

wrote Feb 13, 2013 at 3:09 AM