v8 エンジンの代入演算子(=)のバグ

登録した

ECMAScript 5.1の仕様では

  1. Let lref be the result of evaluating LeftHandSideExpression.

  2. Let rref be the result of evaluating AssignmentExpression.

  3. Let rval be GetValue(rref).

  4. Throw a SyntaxError exception if the following conditions are all true:

  5. Call PutValue(lref, rval).

  6. Return rval.

http://es5.github.com/#x11.13.1

となっており、最後に右辺値を返すことになっている。

ところが、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)

修正された。