svaarala / duktape

Duktape - embeddable Javascript engine with a focus on portability and compact footprint
MIT License
5.97k stars 515 forks source link

Add Support for RegExp Sticky Flag ("y") #2335

Open ghost opened 4 years ago

ghost commented 4 years ago

I was using commit 0e4d5044dcdb764165cc5b6117c5aa09a7f5ed65 from master from June 7th.

After I transpiled @fluent/bundle: https://www.npmjs.com/package/@fluent/bundle

to ES2015 - Duktape got to line 949 (of 1539 lines) and got stuck on this: var RE_ATTRIBUTE_START = new RegExp("\.([a-zA-Z][\w-]) = *", "y");

Duktape Error: SyntaxError: invalid regexp flags at [anon] (/duktape/dist/src-custom/duktape.c:90076) internal at RegExp () native strict construct preventsyield at [anon] (@fluent/bundle:949) strict at [anon] (@fluent/bundle:49) strict at main (@fluent/bundle:1539) strict preventsyield at require () native strict preventsyield at [anon] (eval:4) preventsyield

So it seems Duktape doesn't support the "sticky" flag in Regexp: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/sticky

Thanks!

Tim

svaarala commented 4 years ago

RegExp support is at ES5.1 level at present.

ghost commented 4 years ago

Makes sense - what is the likely timeline for adding this support?

Thanks again!

ben-tbotlabs commented 4 years ago

The RegExp sticky tag was added as part of ECMAScript 2015 (E6). I am also interested in getting support for es2015 RegExp. I have a workaround for the moment, but if this is in the roadmap/near future I might change my implementation.