Closed Bug 421454 Opened 16 years ago Closed 16 years ago

possible wrong semantic of assignment

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 312354

People

(Reporter: feng.qian.moz, Unassigned)

Details

In Acid3 test 95, there is a piece of code like:

var a = []; var s;
s = a.length = '1234';
print(typeof s);
print(typeof a.length);

Safari gives s a string '1234', but FF assigns the number 1234 to s.

Read ECMA-262 spec, I think Safari is correct.

1 1 . 1 3 . 1 Simple Assignment ( = ) 
The production Assignment Expression : LeftHandSideExpression = AssignmentExpression is evaluated 
as follows: 
1. Evaluate LeftHandSideExpression. 
2. Evaluate AssignmentExpression. 
3. Call GetValue(Result(2)). 
4. Call PutValue(Result(1) , Result(3)).
5. Return Result (3).

The return value of 'a.length = "1234"' should be "1234" instead of 'a.length' which is a number.

What do you think?
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.