Closed Bug 275378 Opened 20 years ago Closed 20 years ago

Literal RegExp in case block gives syntax error

Categories

(Core :: JavaScript Engine, defect, P1)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED
mozilla1.8alpha6

People

(Reporter: martin.zvieger, Assigned: brendan)

Details

(Keywords: js1.5)

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910

The JavaScript engine gives a syntax error - the problem is also in Mozilla 1.7.3
Minimal example which demonstrates the behaviour:

// Paste this stuff in some *.js file and load the page

var tmpString= "XYZ";
// works
/ABC/.test(tmpString);
var tmpVal= 1;
if (tmpVal == 1)
{
	// works
	/ABC/.test(tmpString);
}
switch(tmpVal)
{
case 1:
	{
		// works
		/ABC/.test(tmpString);
	}
	break;
}
switch(tmpVal)
{
case 1:
	// fails with syntax error
	/ABC/.test(tmpString);
	break;
}



Reproducible: Always
Component: JavaScript Console → JavaScript Engine
Product: Firefox → Core
Version: unspecified → Trunk
Attached file Testcase
martijn.martijn, please check " Reassign bug to owner and QA contact of selected
component " when changing the component of bugs.
Assignee: bugs → general
QA Contact: firefox.js-console → pschwartau
Confirmed on Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a6)
Gecko/20041219 Firefox/1.0+ (stipe)
Attached patch fixSplinter Review
Assignee: general → brendan
Status: UNCONFIRMED → ASSIGNED
Attachment #169243 - Flags: review?(shaver)
Old bug, easy fix.

/be
Keywords: js1.5
Priority: -- → P1
Target Milestone: --- → mozilla1.8alpha6
Not blocker, just put parentheses around the regexp to work around the bug.

/be
Severity: blocker → major
timeless, feel free to nominate for active branches.

/be
$ cvs ci -m"Twiddle TSF_OPERAND when peeking after switch case label, to scan
regexp literal at start of labeled statement (275378, tachyonal r=shaver)."
jsparse.c
Checking in jsparse.c;
/cvsroot/mozilla/js/src/jsparse.c,v  <--  jsparse.c
new revision: 3.117; previous revision: 3.116
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment on attachment 169243 [details] [diff] [review]
fix

Exactly as I imagined it! r=shaver
Attachment #169243 - Flags: review?(shaver) → review+
Martin, with your permission this test case will be added to the javascript
test library.
(In reply to comment #10)
> Created an attachment (id=174892) [edit]
> js1_5/Regress/regress-275378.js
> Martin, with your permission this test case will be added to the javascript
> test library.
Go with it...
js1_5/Regress/regress-275378.js checked in.
Flags: testcase+
verified fixed 1.8.x and trunk.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: