Closed Bug 346902 Opened 19 years ago Closed 19 years ago

Incorrect uneval involving an expression that optimized to an object literal

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla1.8.1

People

(Reporter: jruderman, Assigned: brendan)

References

Details

(Keywords: testcase, verified1.8.1, Whiteboard: [181approval pending])

Attachments

(1 file, 1 obsolete file)

http://www.squarefree.com/shell/shell.html, Mac trunk nightly > function() { 1 ? {} : 0, alert(3) } function () { {}, alert(3); } > function () { {}, alert(3); } syntax error I'd expect uneval to either put parentheses around the object literal, or optimize it away altogether, leaving only alert(3) in the function.
Assignee: general → brendan
OS: Mac OS X 10.4 → All
Priority: -- → P4
Hardware: Macintosh → All
Target Milestone: --- → mozilla1.9beta
Is this the same bug or something I should file separately? > function() { 1 ? {}[alert(5)] : 0 } function () { {}[alert(5)]; } > function () { {}[alert(5)]; } function () { [alert(5)]; }
(In reply to comment #1) > Is this the same bug or something I should file separately? > > > function() { 1 ? {}[alert(5)] : 0 } > function () { {}[alert(5)]; } This is the bug. > > function () { {}[alert(5)]; } > function () { [alert(5)]; } This is fine -- the empty block has been culled. /be
Status: NEW → ASSIGNED
This one seems worth fixing for 1.8.1. /be
Target Milestone: mozilla1.9beta → mozilla1.8.1
This one seems worth fixing for 1.8.1. /be
Priority: P4 → P2
Attached patch one possible fix (obsolete) — Splinter Review
mrbkap had a neat alterna-patch that used the operator precedence magic coded in jsopcode.tbl, but I think it ran into a contradiction: it wanted prec(ENDINIT) < prec(POP) && prec(POP) < prec(ASSIGN) but to avoid extra parenthesization for x = {p: 2}, we want prec(ASSIGN) < prec(ENDINIT) which makes a cycle in the order chain. So my patch uses brute force in the constant folder. /be
Attachment #234282 - Flags: review?(mrbkap)
Comment on attachment 234282 [details] [diff] [review] one possible fix >+ if (pn->pn_type == TOK_RP) >+ return pn->pn_type == TOK_LP; This can't be what you wanted.
Attachment #234282 - Attachment is obsolete: true
Attachment #234292 - Flags: review?(mrbkap)
Attachment #234282 - Flags: review?(mrbkap)
Attachment #234292 - Flags: review?(mrbkap) → review+
Comment on attachment 234292 [details] [diff] [review] oops, corrected copy/paste bug Another safe fix for uneval | eval round-tripping. /be
Attachment #234292 - Flags: approval1.8.1?
Fixed on the trunk. /be
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Checking in regress-346902.js; /cvsroot/mozilla/js/tests/js1_5/Expressions/regress-346902.js,v <-- regress-346902.js initial revision: 1.1
Flags: in-testsuite+
verified fixed 1.9 20060818 windows/mac(ppc|tel)/linux
Status: RESOLVED → VERIFIED
Whiteboard: [181approval pending]
Comment on attachment 234292 [details] [diff] [review] oops, corrected copy/paste bug a=schrep for drivers - approving all [181approval pending] bugs now that the tree is open.
Attachment #234292 - Flags: approval1.8.1? → approval1.8.1+
Fixed on the 1.8 branch. /be
Keywords: fixed1.8.1
verified fixed 1.8, 1.9 20060824 windows/mac*/linux
Checking in regress-346902.js; /cvsroot/mozilla/js/tests/js1_5/Expressions/regress-346902.js,v <-- regress-346902.js new revision: 1.2; previous revision: 1.1 done
Depends on: 387951
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: