Status: Untriaged
Owner: ----
New issue 4197 by [email protected]: Incorrect error type thrown when
attempting to create cyclic prototype hierarchies
https://code.google.com/p/v8/issues/detail?id=4197
ES6 defines two means for setting an object's prototype: via
`Object.setPrototype` and (in contexts that honor Annex B) via the object's
`__proto__` attribute. Both cases use the well-known internal
[[SetPrototypeOf]] method. When this method determines that completing the
operation would create a cycle in a prototype chain, it makes no changes and
returns `false`. Both `Object.setPrototypeOf` and `set
Object.prototype.__proto__` are specified to throw a TypeError in this case.
Currently, V8 throws a generic Error object.
Version: 8c57b2e16d11af541a64ef876ff2133cdd444233 (Fri Jun 12 08:22:29 2015
-0700)
OS: Ubuntu Linux
Architecture: x64
$ d8 -e 'Object.setPrototypeOf(Object.prototype, {});'
unnamed:1: Error: Cyclic __proto__ value
Object.setPrototypeOf(Object.prototype, {});
^
Error: Cyclic __proto__ value
at Function.setPrototypeOf (native)
at unnamed:1:8
Expected: TypeError
$ d8 -e 'Object.prototype.__proto__ = {};'
unnamed:1: Error: Cyclic __proto__ value
Object.prototype.__proto__ = {}
^
Error: Cyclic __proto__ value
at Object.set __proto__ (native)
at unnamed:1:28
Expected: TypeError
## 9.1.2 [[SetPrototypeOf]] (V)
[...]
6. Let p be V.
7. Let done be false.
8. Repeat while done is false,
a. If p is null, let done be true.
b. Else, if SameValue(p, O) is true, return false.
c. Else,
i. If the [[GetPrototypeOf]] internal method of p is not the
ordinary
object internal method defined in 9.1.1, let done be true.
ii. Else, let p be the value of p’s [[Prototype]] internal slot.
[...]
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v
## 19.1.2.18 Object.setPrototypeOf ( O, proto )
[...]
5. Let status be O.[[SetPrototypeOf]](proto).
6. ReturnIfAbrupt(status).
7. If status is false, throw a TypeError exception.
[...]
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof
## B.2.2.1.2 set Object.prototype.__proto__
[...]
5. Let status be O.[[SetPrototypeOf]](proto).
6. ReturnIfAbrupt(status).
7. If status is false, throw a TypeError exception.
[...]
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-object.prototype.__proto__
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.