Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patched __proto__ (that uses Object.setPrototypeOf) fails and throws TypeError #18

Closed
lauritzthamsen opened this issue Jul 24, 2013 · 4 comments

Comments

@lauritzthamsen
Copy link

There seems to be an issue with how proto is patched to use Object.setPrototypeOf.
Currently, setting the proto property of an object causes a TypeError:

TypeError: Generic use of proto accessor not allowed

The error occurs, for example, when using test/testProxies.html to run testProxies.js in the testSetPrototypeOf.

Is there another way to patch proto?

I used Chrome 29.0.1547.22 beta (with Experimental JavaScript for the old Harmony proxies and Harmony Weak Maps).

My current solution is to prevent the patch (not executing the function after _var _proto__setter), change Object.setPrototypeOf to directly set the proto property, and then consistently use

Object.setPrototypeOf(target, newProto)

instead of

target.proto = newProto

in the project... :-/

tvcutsem pushed a commit that referenced this issue Jul 24, 2013
@tvcutsem
Copy link
Owner

This seems to be an issue with Chrome itself rather than my patch: Chrome advertises Object.prototype.proto as an accessor property with a setter, but actually calling the setter produces an error:

var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype,'__proto__');
protoDesc.set.call({}, {}); // TypeError: Generic use of __proto__ accessor not allowed

I updated reflect.js so that Object.setPrototypeOf throws a 'not supported on this platform' exception on Chrome, as I have no way of implementing it without being able to call the setter. In the new patch, I also leave Object.prototype.__proto__ alone in this case, such that normal uses of object.__proto__ = v should still work.

Update to reflect.js v0.0.7 to see the patch.

I also filed a bug with v8, asking for clarification:
https://code.google.com/p/v8/issues/detail?id=2804

Thanks for reporting.

@lauritzthamsen
Copy link
Author

Wow. Thanks for looking into this, the clarification, and the workaround. And for filing the issue with v8.

@lauritzthamsen
Copy link
Author

This seems fixed. The status of the issue you filed with v8 was set to fixed and worked for me in the most recent Chrome.

Thanks for your help again!

@tvcutsem
Copy link
Owner

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants