Closed
Bug 800909
Opened 12 years ago
Closed 12 years ago
eval("'x' \n + 'y'") returns NaN instead of 'xy' due to automatic semicolon insertion
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 791465
People
(Reporter: mozilla-spam, Unassigned)
Details
(Keywords: qawanted, regression)
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0
Build ID: 20121010144125
Steps to reproduce:
I develop and maintain MozRepl::RemoteObject, a Perl <-> Firefox bridge. The test suite broke after an upgrade from Firefox 15 to Firefox 16.0.1. The (self-contained) Javascript code to exhibit the breakage is below. It seems that string concatenation in an eval() behaves differently from before.
Actual results:
var s = ["\"\\u30C8\\u30EF\\u30FC\\u30AD",
"\\u30F3\\u30B0 \\u30B5\\u30FC\"\n +",
"\"\\u30D3\\u30B9 [mixi(\\u30DF\\u30AF\\",
"u30B7\\u30A3)]\"\n"].join("");
alert(s); // Shows basically the following expression:
var expected= "\u30C8\u30EF\u30FC\u30AD\u30F3\u30B0 \u30B5\u30FC" +"\u30D3\u30B9 [mixi(\u30DF\u30AF\u30B7\u30A3)]";
alert(eval(s)); // is undefined
alert(eval(s) == expected); // that is what I expect
Expected results:
Ideally, the JS behaviour should not change between Firefox releases, or at least be mentioned in the change notes. I could not find such a change note.
On a more technical level, I expect the string-eval to be equivalent to the direct JS code. It seems that two different code paths are taken.
Comment 1•12 years ago
|
||
For some reason the eval comes back with NaN instead of a string concatenation?
Comment 2•12 years ago
|
||
Ah, the issue is the newline before the '+'.
This seems to be triggering automatic semicolon insertion. Should it?
Updated•12 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
Summary: difference in JS (+Unicode) behaviour between Firefox 15 and 16 - string concatenation now returns undef within an eval() → eval("'x' \n + 'y'") returns NaN instead of 'xy' due to automatic semicolon insertion
Updated•12 years ago
|
Keywords: qawanted,
regressionwindow-wanted
Comment 4•12 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #2)
> This seems to be triggering automatic semicolon insertion. Should it?
The golden rule of ASI is that a semicolon is only ever inserted if there'd be a syntax error without it. So, no, there shouldn't be a semicolon inserted here.
Comment 5•12 years ago
|
||
I think this is just a dup.
Status: NEW → RESOLVED
Closed: 12 years ago
No longer depends on: 791465
Keywords: regressionwindow-wanted
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•