1.52 KB, text/html
Status: UNCONFIRMED → NEW
Ever confirmed: true
Just to note, that Roger Lawrence, the assigned person states this is the behaviour in: http://groups.google.com/groups?selm=39205AA8.FE081514%40netscape.com However, that thread doesn't continue and in other ECMAScript implementations it is UA/platform specific as to whether the newlines are included in escaped literals, hence why I feel no fix, but petition ECMA-262 to codify the correct behaviour.
Summary of the escape sequence "\(literal newline character)" NN4.7 (JS1.4) The newline character is treated as any other non-escaped character. Escaping a non-escaped character results in the character itself ("\A" == "A"). Thus the newline character gets included in the string as itself. Moz/N6 (JS1.5) The newline character is discarded and the string is produced without it. No error is thrown. ECMA Ed. 3 7.8.4 String Literals NonEscapeCharacter :: SourceCharacter but not EscapeCharacter or LineTerminator NOTE A LineTerminator character cannot appear in a string literal, even if preceded by a backslash \. The correct way to cause a line terminator character to be part of the string value of a string literal is to use an escape sequence such as \n or \u000A.
Assigning this to Waldemar for a decision - Do we want JS1.5 to throw an error on "\(literal newline character)" ? If not, is the behavior of JS1.4 preferable, in the way it allows this as line continuation for the programmer? From a standards viewpoint, should ECMA be changed to allow this?
Assignee: rogerl → waldemar
OS: Windows 98 → All
Hardware: PC → All
ECMAScript is clear on this -- a backslash followed by any kind of a line break is a syntax error. I don't think we can make this into a syntax error in JS1.5 because of compatibility concerns with existing scripts. In our Edition 4 strict mode implementation I'd expect this to really be a syntax error. An implementation is allowed to (but discouraged from) extend any behavior that the standard says would cause a syntax error, so what we're currently doing in JS1.5 is strictly speaking ECMA-conforming but frowned upon because it confuses scripters and makes scripts unnecessarily nonportable, as illustrated by Jim's analysis above.
Just spoke with Waldemar - marking this one, then, as WONTFIX
Status: NEW → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → WONTFIX
Marking Verified - Jim, thank you for this report.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.