Closed Bug 706211 Opened 13 years ago Closed 13 years ago

JS Correctness: Reference error with "-m -n" vs. no error without options

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
critical

Tracking

()

RESOLVED DUPLICATE of bug 706795

People

(Reporter: decoder, Unassigned)

Details

(Keywords: regression, testcase)

The following test produces an error with options "-m -n" but no error when run without options on mozilla-central revision e320f9f5536f:


var gTestcases = new Array();
function TestCase(n, d, e, a) {
  this.expect = e;
}
function reportCompare (expected, actual, description) {
}
for ( gTc=0; gTc < gTestcases.length; gTc++ ) {  }
function writeHeaderToLog( string ) {}
try {
  var SECTION = "10.1.4-2";
  gTestcases[gTc].expect = (TestCase(SECTION, 0x0F20, 0x0F29, writeHeaderToLog));
} catch(exc1) {}
function c() {
    this.x = 3;
}
Object.prototype.__defineSetter__('x', function(){ actual = expect; })
new c;
reportCompare(expect, actual);



A ReferenceError is thrown depending on the options (where $JS is just the javascript shell binary):

$ $JS -m -n min.js
min.js:18: ReferenceError: actual is not defined
$ $JS min.js (no output)

A further reduced version turned the situation around and threw a ReferenceError only in interpreter mode (without options). I wasn't sure if that is the same issue though so I sticked to this test.
(In reply to Christian Holler (:decoder) from comment #0)
> The following test produces an error with options "-m -n" but no error when
> run without options on mozilla-central revision e320f9f5536f:
> 
> 
> var gTestcases = new Array();
> function TestCase(n, d, e, a) {
>   this.expect = e;
> }
> function reportCompare (expected, actual, description) {
> }
> for ( gTc=0; gTc < gTestcases.length; gTc++ ) {  }
> function writeHeaderToLog( string ) {}
> try {
>   var SECTION = "10.1.4-2";
>   gTestcases[gTc].expect = (TestCase(SECTION, 0x0F20, 0x0F29,
> writeHeaderToLog));
> } catch(exc1) {}
> function c() {
>     this.x = 3;
> }
> Object.prototype.__defineSetter__('x', function(){ actual = expect; })
> new c;
> reportCompare(expect, actual);
> 
> 
> 
> A ReferenceError is thrown depending on the options (where $JS is just the
> javascript shell binary):
> 
> $ $JS -m -n min.js
> min.js:18: ReferenceError: actual is not defined
> $ $JS min.js (no output)
> 
> A further reduced version turned the situation around and threw a
> ReferenceError only in interpreter mode (without options). I wasn't sure if
> that is the same issue though so I sticked to this test.

Can you post that test case too in case it's easier to debug?
(In reply to David Mandelin from comment #1)
> Can you post that test case too in case it's easier to debug?

Sure:

var gTestcases = new Array();
function c() {
    this.x = 3;
}
Object.prototype.__defineSetter__('x', function(){ actual = expect; })
new c;


That test throws "ReferenceError: expect is not defined" when run without any options, but does not give any error when run with "-m -n".
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Tracking the original.
You need to log in before you can comment on or make changes to this bug.