17:04
<bakkot>
what are the odds we could get away with changing String.prototype.indexOf so that if you pass a regex it will actually use it instead of coercing to a string
17:04
<bakkot>
my feeling is unfortunately low
17:04
<bakkot>
(I'm thinking something like, if the argument is not primitive then look up Symbol.exec and use that instead of doing .toString)
17:05
<bakkot>
presumably someone is somehow relying on like 'foo/bar/baz'.indexOf(/bar/) returning 3
17:06
<Mathieu Hofman>
presumably someone is somehow relying on like 'foo/bar/baz'.indexOf(/bar/) returning 3
Sounds like something that browsers can easily add a use counter for if you can convince them
17:07
<bakkot>
browsers could add a use counter for regexp arguments but it's hard to automatically tell if someone is relying on it working (or not working)
17:19
<Michael Ficarra>
well if they're not used at all, you don't have to worry about that
17:19
<Michael Ficarra>
unfortunately, I highly doubt that nobody is doing it
19:00
<shu>
my feeling is also the odds are not good
19:12
<ljharb>
if you need a regex with a string, isn't that already String.prototype.search?
19:26
<bakkot>
well, I want the offset argument instead of mutating the regex
19:27
<bakkot>
but yeah I guess
19:27
<bakkot>
much more likely we could get away with adding a second argument there
19:27
<bakkot>
I did forget that String.prototype.search exists
19:28
<bakkot>
oh actually search doens't even respect lastIndex so yeah it's not suitable at all currently
19:28
<bakkot>
but it could be made to take the second parameter
19:29
<bakkot>
... possibly, anyway
21:31
<ljharb>
yeah it is weird that it ignores lastIndex
21:57
<bakkot>
doesn't just ignore but actively mangles such that it throws if you try to pass a RegExp with a frozen nonzero lastIndex
21:57
<bakkot>
what a dumb language