paulmillr / es6-shim

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

RegExp constructor w/o arguments broken #350

Closed zloirock closed 9 years ago

zloirock commented 9 years ago
RegExp(); // => TypeError: Cannot read property 'constructor' of undefined, should be equal RegExp('')

21.2.3.2.2, step 1

Critical, breaks some libraries

For example,

npm i es6-shim sugar
iojs
> require('es6-shim');
> require('sugar');
>>> TypeError: Cannot read property 'constructor' of undefined
ljharb commented 9 years ago

Wow, thanks, great catch. Fix incoming.

zloirock commented 9 years ago

It does not cover

RegExp(null);
RegExp(undefined);
ljharb commented 9 years ago

Thanks, will fix that now.