What's the correct behavior for "\8" and "\9"

BelleveInvis infinte.cdda at hotmail.com
Mon Mar 25 00:38:30 PDT 2013


But, according to spec, "\8" and "\9" SHOULD cause a syntax error.
Because in string literals, 
EscapeSequence -> CharacterEscapeSequence
and
CharacterEscapeSequence -> SingleEscapeCharacterCharacterEscapeSequence -> NonEscapeCharacter
The NonEscapeCharacter is defined as SourceCharacter minus SingleEscapeCharacter, DecimalDigit, x and u, therefore, 8 and 9 (belongs to DecimalDigit) SHOULD NOT be an element of SingleEscapeCharacter, then not a member of EscapeSequence, therefore, "\8" and "\9" SHOULD be illegal according to the spec.

> Date: Sun, 24 Mar 2013 21:38:50 -0700
> From: brendan at mozilla.com
> To: infinte.cdda at hotmail.com
> CC: allen at wirfs-brock.com; es-discuss at mozilla.org
> Subject: Re: What's the correct behavior for "\8" and "\9"
> 
> Right. Here's SpiderMonkey's shell:
> 
> js> "\8"
> "8"
> js> "\9"
> "9"
> js> "\08"
> "\x008"
> js> "\09"
> "\x009"
> js> "use strict"; "\8"
> "8"
> js> "use strict"; "\9"
> "9"
> js> "use strict"; "\08"
> typein:7:0 SyntaxError: octal literals and octal escape sequences are
> deprecated:
> typein:7:0 "use strict"; "\08"
> typein:7:0 ..............^
> js> "use strict"; "\09"
> typein:8:0 SyntaxError: octal literals and octal escape sequences are
> deprecated:
> typein:8:0 "use strict"; "\09"
> typein:8:0 ..............^
> 
> /be
> 
> BelleveInvis wrote:
> > However, \8 and \9 DOES NOT belong to OctalEscapeSequences. There is
> > NO octal number contains 8 or 9.
> >
> > ------------------------------------------------------------------------
> > Subject: Re: What's the correct behavior for "\8" and "\9"
> > From: allen at wirfs-brock.com
> > Date: Sun, 24 Mar 2013 17:22:13 -0700
> > CC: brendan at mozilla.com; es-discuss at mozilla.org
> > To: infinte.cdda at hotmail.com
> >
> >
> > On Mar 24, 2013, at 6:32 AM, BelleveInvis wrote:
> >
> >     However, even in the newest draft, "\8" still should cause a
> >     syntax error. Should we change the production
> >     "/EscapeCharacter/->/DecimalDigit/" into
> >     "/EscapeCharacter/->/OctalDigit/" in order to make 8 and 9 belongs
> >     to/NonEscapeCharacter/?
> >
> >
> > Probably, but need to look carefully at any possible spec.
> > interactions with OctalEscapeSequences defined in Annex B. (Note that
> > in ES5 we make octal escapes illegal in strict mode code, but they are
> > still allowed in non-strict code)
> >
> > Allen
> >
> >
> >
> >
> >
> >     > Date: Sat, 23 Mar 2013 13:58:41 -0700
> >     > From:brendan at mozilla.com <mailto:brendan at mozilla.com>
> >     > To:infinte.cdda at hotmail.com <mailto:infinte.cdda at hotmail.com>
> >     > CC:es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
> >     > Subject: Re: What's the correct behavior for "\8" and "\9"
> >     >
> >     > BelleveInvis wrote:
> >     > > According to spec: Syntax error, because of that 8 or 9 does not
> >     > > belongs to /NonEscapeCharacter/.
> >     > > However, ALL browsers treat them as "8" and "9".
> >     >
> >     > Web compatibility seems to require "noctal" escapes in string
> >     literals.
> >     > No one has really investigated how much web content, but it was
> >     true in
> >     > the past and engines don't like taking risk for little gain.
> >     >
> >     > /be
> >     _______________________________________________
> >     es-discuss mailing list
> >     es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
> >     https://mail.mozilla.org/listinfo/es-discuss
> >
> >
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130325/dcc5c0f8/attachment.html>


More information about the es-discuss mailing list