v8 エンジンの代入演算子(=)のバグ
登録した
ECMAScript 5.1の仕様では
http://es5.github.com/#x11.13.1
Let lref be the result of evaluating LeftHandSideExpression.
Let rref be the result of evaluating AssignmentExpression.
Let rval be GetValue(rref).
Throw a SyntaxError exception if the following conditions are all true:
IsStrictReference(lref) is true
Type(GetBase(lref)) is Environment Record
GetReferencedName(lref) is either
"eval"
or"arguments"
Call PutValue(lref, rval).
Return rval.
となっており、最後に右辺値を返すことになっている。
ところが、GoogleChromeやnode.jsで、拡張不可なオブジェクトのプロパティへの代入を行うとundefined
が返る。
var o = Object.preventExtensions({}); o.a = "A"; // undefined が返る。本来は "A" となる var a = o.a = "B"; a; // undefined 本来は "B" となる
Firefox, Opera では問題なく仕様どおりであった。
追記(2012-02-24)
修正された。