-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix CoreScalarResolver.INT regex to work with JS #403
Conversation
Can you explain further, please? The change you made does not change any functionality as long as whole strings are matched and even then the test would not fail as even a substring match would hold, besides that the change is part of my readability PR, just with non-capturing groups. |
@Vampire the regex before this change led to test failures in #397. See this run: https://github.com/krzema12/snakeyaml-engine-kmp/actions/runs/13174353963/job/36770339573 and the build scan: https://scans.gradle.com/s/k4ayl4yetgdve/tests/overview?outcome=Failed. The change merged in this PR fixes the problem, that's it. For me, this proof is enough. We'll convert the group into a non-capturing one in your regex-related PR. |
@Vampire if course if you see a other reason why the tests failed, let me know! This case also intrigued me, so I want to understand it well. |
I had a closer look and it is like I said, it doesn't make any sense.
The problem is, that the K/JS Implementation at https://github.com/JetBrains/kotlin/blob/de5284d7e4af5b94d9d4144119134eb0285a5fa9/libraries/stdlib/js/src/kotlin/text/regex.kt#L97 is bullshit. It executes the regex against the input, gets a result that might only match a part (in this case just Have a look at https://pl.kotl.in/sfmoOkwcB. With JVM all four cases are correctly |
Actually due to that bug, you should probably go through all regexes and check whether they are intended to match the entire input and add the anchors and non-matching group of they should. In my PR I only fixed the cases you fixed here, where the group was missing. |
Nice find! Indeed So yeah, this PR turns to be a workaround for the issue you found. Are you planning to report it? |
No, I'm planning to fix it, I don't have a commit in Kotlin yet. :-D |
Actually it is even worse. |
Found when converting the corresponding test to KMP: #397
What helped me here is this tool that renders the regex as a graph: https://www.debuggex.com/
Before the fix - I noticed that

^
and$
are attached to the groups nearest to them:After the fix - creating a new group that contains the rest fixes the problem:
