paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 389 forks source link

Map/Set error message is misleading #321

Closed webbedspace closed 9 years ago

webbedspace commented 9 years ago

The error message for calling Map without a function is 'Map does not accept arguments when called as a function', but it should really read 'Map cannot be called as a function'. Ditto Set.

(In the current spec, Map will always throw without the new keyword, regardless of arguments.)

ljharb commented 9 years ago

Thanks, these messages are what current engines that implemented Map/Set threw, but now io.js's v8 implements them correctly, I'll update them to use their messages.

webbedspace commented 9 years ago

In addition, you should (if possible) update it so that Map.call(new Map()) throws an error (ditto Set).

ljharb commented 9 years ago

I'm not sure if that's possible - NewTarget can't be shimmed or detected.