-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Identical Regexp are not equal to each other #4259
Comments
@andy-twosticks Nice find! This would point to a difference in how the parser constructs Regex versus how the constructor forms construct Regex. |
@enebo Any idea why this might be? Something odd with the escaping? |
@headius My only guess would be that bytelist after parsing does not remove the \ and it does it in the constructor of the regexp. That would make the bytelists different perhaps? |
It looks like the sources are difference in these two cases.
|
Ok, so stepping through the parser showed me that it's constructing the Seems like either the one needs to be escaped or the other needs to be unescaped before constructing the Regexp. |
Ruby 2.3 for comparison:
|
A bit more comparison with MRI:
We produce the same tokens, but when combining those string pieces we seem to be escaping the |
So there was an extra append '' in our StringTerm code which MRI did not have nor did our ripper version of StringTerm. So pretty easy to delete that line. Spec added in commit b0abc53. |
Environment
Expected Behavior
Regardless of how a Regexp is created or what it contains, identical Regexp should always be equal to each other.
The behaviour below turns up in MRI 1.9.3, too, but appears to be gone by 2.0.0:
Actual Behavior
As you can see, the problem seems to be with Regexp created using the basic slash syntax when the regexp itself also contains a slash.
The text was updated successfully, but these errors were encountered: