-
Notifications
You must be signed in to change notification settings - Fork 396
Pattern matcher groupCount throws #1727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unfortunately, this is virtually not fixable. With a JS regexp, there is no way to get the group count without having a successful match. So either we parse the regexp on an ad hoc basis to get that count (hard), or we derive automatically a matching string from the regexp to match against it (which requires to parse the regex in the first place). Unless someone else has an idea... |
Yet another issue that would be solved by our own regex parser as proposed in #1201 |
I played around with JS RegExps and read some ref doc - definitely doesn't seem possible. Regex continues to be the largest source of incompatible Scala/Scala.JS behaviour. It's a significant problem because you only hit the errors at runtime - compilation & linking passes silently. The only way to catch incompatibilities like this one, unsupported regex like |
I'll close this as Won't Fix. If it must be fixed, it will go into the larger scheme of things of fixing #1201 anyway. |
For people having a problem with
If the call to groupCount fails, it tries to enumerate the groups and return the inferred count. It saved my tool (scalajs 0.6.19) |
Thanks @MikaelMayer for the fix, it works for me too. @sjrd is this something we could fold into the stldlib |
I don't think so, because the workaround builds on top of Scala's |
The following snippet behaves very differently in Scala.JS vs JVM.
In JVM, it prints 2. In JS it throws
java.lang.IllegalStateException: No match available
.The text was updated successfully, but these errors were encountered: