Fun impossible Firefox JS challenge
rossberg at google.com
Fri Apr 13 08:19:13 PDT 2012
On 13 April 2012 16:47, Brendan Eich <brendan at mozilla.org> wrote:
> Some time after Firefox 4, a fix went in so we match ES5:
> js> fals\u0065
Hm, I still don't quite see where ES5 would specify this behaviour.
The relevant bits I can find are:
- In 5.1.6: "Terminal symbols of the lexical, RegExp, and numeric
string grammars, and some of the terminal symbols of
the other grammars, are shown in `fixed width` font, both in the
productions of the grammars and throughout this specification whenever
the text directly refers to such a terminal symbol. These are to
appear in a program exactly as written."
- In 7.8.2, the 'false' literal is defined in the aforementioned fixed
- In 7.6, the grammar of identifiers is given to allow unicode
escapes, but excludes ReservedWords, which in turn include the
aforementioned literals (in their verbatim form!).
- Also in 7.6, the spec says: "A UnicodeEscapeSequence cannot be used
to put a character into an IdentifierName that would otherwise be
illegal. In other words, if a \ UnicodeEscapeSequence sequence were
replaced by its UnicodeEscapeSequence's CV, the result must still be a
valid IdentifierName that has the exact same sequence of characters as
the original IdentifierName."
- Going on, the spec says "All interpretations of identifiers within
this specification are based upon their actual characters regardless
of whether or not an escape sequence was used to contribute any
>From the first 3 points I conclude that `fals\u0065` is not the
'false' literal. It would be an identifier if it wasn't for the 4th
point. Consequently, the token `fals\u0065` is neither a literal nor
The last point merely seems to be talking about "interpretation" of
tokens that have already been syntactically classified as identifiers.
I.e. it does not turn `fals\u0065` into a literal again, it only
results in `f\u0065` denoting the same identifier as `\u0066e`.
In any case, this should really be clarified.
More information about the es-discuss