Closed Bug 246911 Opened 20 years ago Closed 20 years ago

misbehave of switch() statement with variable as label

Categories

(Core :: JavaScript Engine, defect)

Other Branch
x86
Windows 2000
defect
Not set
major

Tracking

()

VERIFIED FIXED

People

(Reporter: thingol, Assigned: shaver)

Details

(Keywords: verified1.7, Whiteboard: fixed-aviary1.0)

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040206 Firefox/0.8
Build Identifier: Firefox/0.9

This code:
var a = 10;
a = 9;
var b = 10;
switch(b)
{
 case a:
  alert('got it');
  break;
 default:
  alert('passed');
}
give 'passed' in all browsers including MSIE & FireFox 0.8, but gives 'got it'
under FireFox 0.9.

As it seems to me, it's a bug.

Reproducible: Always
Steps to Reproduce:
1. Write your code with switch() statement using variables as labels.

Actual Results:  
Variable are always constant in switch() statement.

Expected Results:  
Variable must change its value when I change it.
Something bad in the browser embeddings.  We can't reproduce this in the shells,
AFAIK.

/be
Status: UNCONFIRMED → NEW
Ever confirmed: true
Hmm, trunk builds pass too, is this aviary branch only?
Hmm, if I copy the JS engine source into my aviary branch tree and rebuild, the
bug goes away. Did something get fixed on the trunk and not on the aviary
branch, or was something incorrectly merged?
This happens on the 1.7 branch as well, so unlikely a aviary branch merge problem.
Found it.  Patch coming up now.
Assignee: general → shaver
Looking for quick r/sr for "obvious" fix.  Risk very limited: might cause us to
miss a chance to optimize a constant, at absolute worst.
Comment on attachment 150869 [details] [diff] [review]
only define compile-time constants for JSOP_DEFCONST

Curse me for sneaking a fix into a big landing.  I had completely forgotten
about this!

/be
Attachment #150869 - Flags: review+
Attachment #150869 - Flags: approval1.7+
In case it's unclear, this fix has been on the trunk a while.  It's good for the
aviary branch too; I think Ben is syncing up.  Someone slap the right keywords
or status whiteboard on this bug and resolve it.

/be
looks like this has been checked in to 1.7 and aviary now, so slapping as requested.
Status: NEW → RESOLVED
Closed: 20 years ago
Keywords: fixed1.7
Resolution: --- → FIXED
Whiteboard: fixed-aviary1.0
Version: Trunk → Other Branch
We need a test case for this in the suite, I beseech thee!
using the reporters test case with 1.7, this is verified.
Status: RESOLVED → VERIFIED
Keywords: fixed1.7verified1.7
Roman, with your permission this will be included in the javascript test
library.
> Roman, with your permission this will be included in the javascript test
> library.

Yes, of course.

Thank you very much.
js1_5/Regress/regress-246911.js checked in.
Flags: testcase+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: