Open tesk9 opened 6 years ago
I just found this out too, here's an Ellie repro: https://ellie-app.com/4wHwRvs79mSa1
This also affects splitting on word boundaries with Maybe.withDefault Regex.never (Regex.fromString "\\b")
. The issue is in the while loop in _Regex_splitAtMost
: start = re.lastIndex;
assumes that start
will increase by a nonzero amount, but re.lastIndex
is zero in this case. For what it's worth this works with the native JS implementation 'word-kebab'.split(/\b/)
produces [ 'word', '-', 'kebab' ]
. My thanks to @brian-carroll for finding this. @lydell also pointed out that per ECMA the pointer should move forward by AdvanceStringIndex
when the match has zero width, which basically advances the pointer by one then keeps going to the end of the code point. Of course, we're not making an ECMA compliant language, but it's a good reference for reimplementing regex split matching.
Splitting on a
Regex
from an empty string ("") leads to a page crash.I think I would expect for the behavior to match
Regex.never
: