Skip to content
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

Matcher region not mutating the matcher #4203

Closed
thesamet opened this issue Sep 22, 2020 · 2 comments · Fixed by #4205
Closed

Matcher region not mutating the matcher #4203

thesamet opened this issue Sep 22, 2020 · 2 comments · Fixed by #4205
Assignees
Labels
bug Confirmed bug. Needs to be fixed.
Milestone

Comments

@thesamet
Copy link

Matcher.region() is returning an instance of a new matcher with the given start and end position:

def region(start: Int, end: Int): Matcher =
new Matcher(pattern0, input0, start, end)

The behavior on the JVM is that the region is updated in-place: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#region(int,%20int)

@sjrd
Copy link
Member

sjrd commented Sep 22, 2020

Thanks for the report :)

@sjrd sjrd added the bug Confirmed bug. Needs to be fixed. label Sep 22, 2020
@sjrd sjrd added this to the v1.2.1 milestone Sep 22, 2020
@thesamet
Copy link
Author

As a workaround, I changed my instance to var so I can re-assign the returned value to the same variable (rather than mutating). I then noticed at least one more inconsistency with the JVM object that triggered IllegalStateException. I'll file a separate bug later.

@gzm0 gzm0 self-assigned this Sep 23, 2020
gzm0 added a commit to gzm0/scala-js that referenced this issue Sep 23, 2020
@gzm0 gzm0 linked a pull request Sep 23, 2020 that will close this issue
gzm0 added a commit to gzm0/scala-js that referenced this issue Sep 23, 2020
gzm0 added a commit that referenced this issue Sep 23, 2020
Fix #4203: Mutate the Matcher in Matcher#region
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug. Needs to be fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants