-
Notifications
You must be signed in to change notification settings - Fork 48
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
automatic unwrapping #16
Comments
The offending call to WeakMap.get is here
But there are a number of other identical So I suggest a patch something like
at each of those call sites, though perhaps you have a better way of specifying that test. I'll send a PR which you are free to accept or improve upon. |
You'll need to account for functions, since this is also used on function isObject(o){
var type = typeof o;
return type === 'object' ? o !== null : type === 'function';
} |
Thank you -- that's right. I don't have a super deep background in Javascript, so I'll ask: is there a known way of nesting these checks in the right order for best performance, or is it ok (from a performance perspective) to just call WeakMap.get and let it figure out what's an object and throw errors which we catch, like:
|
before invoking WeakMap.get(). Fixes tvcutsem#16. Tests run (and passed) under node v0.10 with --harmony: test/testHandlers.js test/testReflect.js test/testRegression.js
Fix #16: don't pass primitives to WeakMap.get
@metamatt thanks for the PR. Couldn't have done it better myself. I merged it, added unit tests to |
Thanks Tom! |
I believe this behavior was introduced in harmony-reflect v0.0.5 while fixing #13.
The auto-unwrapping assumes Object.prototype.toString will only be called on objects. But lots of code calls it on other types to figure out what type they're dealing with.
Here's what one would normally expect for this behavior:
Here's what you get with harmony-proxies v0.0.5:
The text was updated successfully, but these errors were encountered: