Closed Bug 349493 Opened 18 years ago Closed 18 years ago

Let expression in ternary decompiles incorrectly

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla1.8.1

People

(Reporter: jruderman, Assigned: mrbkap)

References

Details

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

Attachments

(1 file)

> function (x) { return x ? 0 : let (a = 3) a; } function (x) { return x ? 0 : let (3 = 3) a; } "let (3 = 3)" doesn't make much sense, and causes "missing variable name" if you try to eval it.
This was an old bug in the stack-depth modeling in the code generator. If you try to run your function in a debug build, you'll note that it asserts because the stack is off by one.
OS: Mac OS X 10.4 → All
Priority: -- → P1
Hardware: Macintosh → All
Target Milestone: --- → mozilla1.8.1
Attached patch Fix (deleted) — Splinter Review
We needed to adjust the stack depth *before* emitting the else clause.
Assignee: general → mrbkap
Status: NEW → ASSIGNED
Attachment #234824 - Flags: review?(brendan)
Comment on attachment 234824 [details] [diff] [review] Fix Safe and simple fix to an old latent bug that formerly just over-budgeted stack space, but not with let (block scope) is more serious. /be
Attachment #234824 - Flags: review?(brendan)
Attachment #234824 - Flags: review+
Attachment #234824 - Flags: approval1.8.1?
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Flags: blocking1.8.1?
Checking in regress-349493.js; /cvsroot/mozilla/js/tests/js1_7/block/regress-349493.js,v <-- regress-349493.js initial revision: 1.1
Flags: in-testsuite+
Blocks: js1.7let
Flags: blocking1.8.1? → blocking1.8.1+
Whiteboard: [181approval pending]
Comment on attachment 234824 [details] [diff] [review] Fix a=schrep for drivers - approving all [181approval pending] bugs now that tree is open.
Attachment #234824 - Flags: approval1.8.1? → approval1.8.1+
*** Bug 349653 has been marked as a duplicate of this bug. ***
Fixed on the 1.8 branch. /be
Keywords: fixed1.8.1
verified fixed 1.8, 1.9 20060824 windows/mac*/linux
Status: RESOLVED → VERIFIED
I presume the new behavior is correct? FAILED!: [reported from test()] Decompilation of let expression in ternary FAILED!: [reported from test()] Expected value 'function (x) { FAILED!: [reported from test()] return x ? 0 : let (a = 3) a; FAILED!: [reported from test()] }', Actual value 'function (x) { FAILED!: [reported from test()] return x ? 0 : (let (a = 3) a); FAILED!: [reported from test()] }' FAILED!: [reported from test()] updating test to reflect the "actual" value Checking in regress-349493.js; /cvsroot/mozilla/js/tests/js1_7/block/regress-349493.js,v <-- regress-349493.js new revision: 1.2; previous revision: 1.1 done
(In reply to comment #10) > I presume the new behavior is correct? > > FAILED!: [reported from test()] Decompilation of let expression in ternary > FAILED!: [reported from test()] Expected value 'function (x) { > FAILED!: [reported from test()] return x ? 0 : let (a = 3) a; > FAILED!: [reported from test()] }', Actual value 'function (x) { > FAILED!: [reported from test()] return x ? 0 : (let (a = 3) a); > FAILED!: [reported from test()] }' Nothing wrong with extra parens here, and they come about naturally due to the bytecode precedence of let expression vs. ?:. The test should change to match the decompiler, or else tolerate parens or no parens (but only that difference). /be
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: