Closed Bug 351336 Opened 19 years ago Closed 19 years ago

Loss of parens in "for" initial-expression using "in" operator causes syntax error

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla1.8.1

People

(Reporter: jruderman, Assigned: brendan)

Details

(Keywords: testcase, verified1.8.1)

Attachments

(1 file)

> function () { for (("p" in a); 0;) { } } function () { for ("p" in a; 0;) { } } > function () { for ("p" in a; 0;) { } } SyntaxError on line 1: invalid for/in left-hand side This could be fixed by: (1) Keeping the parens intact during decompilation (see also bug 351104, a round-trip change that involves loss of parens in a "for" initial-expression) (2) Allowing the second line to compile, by not treating the "in" as an attempt to create a for-in loop if there's a semicolon present.
(In reply to comment #0) > > function () { for (("p" in a); 0;) { } } > function () { for ("p" in a; 0;) { } } > > > function () { for ("p" in a; 0;) { } } > SyntaxError on line 1: invalid for/in left-hand side > > This could be fixed by: > > (1) Keeping the parens intact during decompilation (see also bug 351104, a > round-trip change that involves loss of parens in a "for" initial-expression) > > (2) Allowing the second line to compile, by not treating the "in" as an attempt > to create a for-in loop if there's a semicolon present. (1) is the only way, as (2) requires either unbounded lookahead for a top-down parser, or a bottom-up parser, and requiring either of those implementations is neither desirable nor conformant with ECMA-262. /be
OS: Mac OS X 10.4 → All
Hardware: Macintosh → All
Attached patch fixSplinter Review
Simple patch (this is against the 1.8 branch; trunk patch is the same unless the patch for bug 350531 gets review soon -- hint hint ;-). /be
Assignee: general → brendan
Status: NEW → ASSIGNED
Attachment #236739 - Flags: review?(mrbkap)
Priority: -- → P2
Target Milestone: --- → mozilla1.8.1
Attachment #236739 - Flags: review?(mrbkap) → review+
Fixed on trunk. /be
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Attachment #236739 - Flags: approval1.8.1?
Comment on attachment 236739 [details] [diff] [review] fix a=schrep for drivers.
Attachment #236739 - Flags: approval1.8.1? → approval1.8.1+
Fixed on the 1.8 branch. /be
Keywords: fixed1.8.1
Checking in regress-351336.js; /cvsroot/mozilla/js/tests/js1_5/Regress/regress-351336.js,v <-- regress-351336.js initial revision: 1.1
Flags: in-testsuite+
verified fixed 1.8, 1.9 20060906 windows/mac*/linux
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: