tvcutsem / harmony-reflect

ES5 shim for ES6 Reflect and Proxy objects
http://www.ecma-international.org/ecma-262/6.0/#sec-reflection
Other
478 stars 48 forks source link

'Illegal access' error when using Object.assign() #72

Closed zvchei closed 8 years ago

zvchei commented 8 years ago

I am using harmony-reflect@1.4.5 and node v4.2.6

Running the following code throws the error:

> const a = { some: 'object' }
> const p = new Proxy(a, {})
> Object.assign({}, a)
illegal access
tvcutsem commented 8 years ago

It appears the new ES6 Object.assign built-in does not like being applied to harmony-era proxy objects. My fix is to polyfill Object.assign such that when any of the arguments passed to Object.assign is a Proxy, I use the polyfill defined here. When no argument is a proxy, I use the built-in version of Object.assign.

Will soon publish as reflect@1.4.6.