Is \u006eew a valid Identifier?

Caitlin Potter caitpotter88 at gmail.com
Mon Nov 9 18:39:54 UTC 2015


`var x = “\u006eew”;` has a different meaning in the grammar, as compared with `var \u006eew = x;`.

Since you can’t declare `var new`, there is no good reason why you should be able to declare `var \u006eew;`.

On a similar note, allowing escaped keywords to have the same semantic meaning as the keywords (which would break allowing them as Identifiers anyways), is a problem. A naive user-input sanitizer could cause a page to be defaced, or worse, arbitrary code evaluated on a web-server, in the case of an input like `(f\u{75}nction() { /* somethingSneaky */ })();`.

Given that, these seem like perfectly good reasons not to allow it in the language.

> On Nov 9, 2015, at 1:25 PM, Coroutines <coroutines at gmail.com> wrote:
> 
> On Mon, Nov 9, 2015 at 10:10 AM, Isiah Meadows <isiahmeadows at gmail.com> wrote:
>> Is there a reason why escapes like that in the title shouldn't evaluate to
>> keywords? To be honest, it's bad style, but I don't get how it would be
>> breaking the Web.
> 
> This.  I do not understand this either.
> 
> If you were to write:
> 
> var x = "\u006eew";
> 
> it'd be obvious that you're referring to the codepoint in the source
> (written in ASCII or something ASCII-compatible) so that it doesn't
> get garbled in the editors of your fellow programmers who might not be
> using the same locale.
> 
> It's strange that you would do that in an identifier because in no
> one's editor would the editor replace it with the unicode character it
> refers to.
> 
> I've always thought JS identifiers were a little too liberal with what
> is allowed, and in that spirit I think it should continue - but Grumpy
> Cat[1] disapproves.
> 
> 1: http://img2-2.timeinc.net/people/i/2014/pets/news/141124/grumpy-cat-800.jpg
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 881 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151109/e0d0065f/attachment.sig>


More information about the es-discuss mailing list