this vs thi\u0073

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Jun 21 01:11:02 PDT 2011


On Jun 21, 2011, at 12:50 AM, Luke Hoban wrote:

> My read of the spec is that thi\u0073 is a ReservedWord and should not be allowed as an Identifer.  So the following part of the examples quoted below should be an early error:
> 
>  var thi\u0073 = 42;
> 
> The text in 7.6 seems to address this with:
> 
> "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 particular characters."
> 
> Luke

+1

I can't dig into the spec. right now but the section Luke quoted  is the one I was going to try to dig for.

Allen









> 
> -----Original Message-----
> From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Mike Samuel
> Sent: Monday, June 20, 2011 2:18 PM
> To: Oliver Hunt
> Cc: es-discuss
> Subject: Re: this vs thi\u0073
> 
> 2011/6/20 Oliver Hunt <oliver at apple.com>:
>> Without looking at the spec but just based on what I know our lexer (JSC) does, we won't consider any identifier with escaped characters to be a keyword, so yes you could make identifiers that technically match language keywords, but you'd never be able to use them directly (without escaping).
> 
> You can due to global object aliasing.
> 
>  var thi\u0073 = 42;
>  alert([this.this === 42,  // Look ma, no escaping!
>          this["this"] === 42]);  // Look ma, still no escaping!
> 
> works in Firefox.
> 
> The first is legal because MemberExpression is defined as
>     MemberExpression . IdentifierName
> not
>     MemberExpression . Identifier
> and it is only Identifier that is not allowed to be a reserved word
>     Identifier :: IdentifierName but not ReservedWord
>     IdentifierName :: IdentifierStart
>          | IdentifierName IdentifierPart _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list