NaN added to an object when optimization is used

RESOLVED FIXED

Status

Rhino
Core
RESOLVED FIXED
10 years ago
9 years ago

People

(Reporter: Ludovic Claude, Assigned: Norris Boyd)

Tracking

Details

Attachments

(2 attachments)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
Build Identifier: Rhino 1.6R5 and 1.7R1

Hello,

I found a bug in the optimized Javascript code where calling a (slightly hacked) function which adds a new key/value pair into an object adds instead NaN/value to that object. 

I have created a JUnit test reproducing that bug. 

Thanks, Ludovic

Reproducible: Always

Steps to Reproduce:
Unit test provided
Actual Results:  
{NaN:"value"}

Expected Results:  
{key:"value"}
(Reporter)

Comment 1

10 years ago
Created attachment 321232 [details]
Unit test for this optimization bug

This unit test fails with both Rhino 1.6R5 and Rhino 1.7R1 on Windows XP / JDK 1.4.2_13
(Reporter)

Comment 2

10 years ago
Created attachment 321237 [details]
Simpler Unit test for this optimization bug

I removed the class inheritance thing which was causing lots of clutter. The minimal code triggering this bug is actually quite simple.
(Assignee)

Comment 3

9 years ago
Fixed: 

Checking in src/org/mozilla/javascript/optimizer/Optimizer.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/optimizer/Optimizer.java,v  <--  Optimizer.java
new revision: 1.51.2.1; previous revision: 1.51
done
RCS file: /cvsroot/mozilla/js/rhino/testsrc/doctests/Attic/434041.doctest,v
done
Checking in testsrc/doctests/434041.doctest;
/cvsroot/mozilla/js/rhino/testsrc/doctests/Attic/434041.doctest,v  <--  434041.doctest
new revision: 1.1.2.1; previous revision: 1.1
done

Checking in src/org/mozilla/javascript/optimizer/Optimizer.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/optimizer/Optimizer.java,v  <--  Optimizer.java
new revision: 1.53; previous revision: 1.52
done
Checking in testsrc/doctests/434041.doctest;
/cvsroot/mozilla/js/rhino/testsrc/doctests/434041.doctest,v  <--  434041.doctestnew revision: 1.2; previous revision: 1.1
done
Assignee: nobody → norrisboyd
Status: UNCONFIRMED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.