-
Notifications
You must be signed in to change notification settings - Fork 188
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
StringScanner::scan behaviour differs wrt MRI #1544
Comments
require 'strscan'
scanner = StringScanner.new("a b")
p scanner.scan(/[a-z]+/)
p scanner.scan(/^\s+/)
p scanner.scan(/[a-z]+/) |
I think this is possibly covered by this failing spec
I'll fix that and the other failing specs for |
Fix on the way. |
Fixed in df10d7a. It's not the best fix in the world because it has to create a new pattern in some cases, but it now passes the spec. |
@chrisseaton - the fix for this is a bit limited. If the regex does not begin with However, there are plenty of ways to introduce /(^.)/
/a|^b/ etc. Using a modified version of the code in the original issue:
I bring this up because I'd like to test Brakeman on TruffleRuby. Brakeman depends on ruby_parser, which uses StringScanner extensively, and happens to have (at least one) regex where this occurs. Let me know if you'd like this to be filed as a separate issue. |
Yes the fix was a bit of a hack! We'll keep thinking. |
We're working on this. |
A proper fix for this is currently going through CI.at the moment. |
The fix has been merged into |
Hi, Sorry to continue poking at this, but...
Please let me know if you'd like this in a separate issue. Thanks! |
For information, the reason it's so complicated is that we try to avoid copying strings. The regular expression implementation we use (JONI) isn't set up for our persistent data structures and we're having a bit of trouble matching the two up. |
Tested with 1.0-RC11
Difference in behaviour is (I think) due to the anchor in
/^\s+/
. This test passes on MRI, fails with Truffle.The text was updated successfully, but these errors were encountered: