-
Notifications
You must be signed in to change notification settings - Fork 176
Increment cursor to breakpoint + 2 #3290
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
Conversation
When there is a `\r\n` in the following example: `p eval "%\n1\r\n \n"` Prism was returning `"1\n "` whereas parse.y returns `"1"`. In this case the cursor needs to be set to the breakpoint (which is `\r`) plus 2 to ignore the new line and the space. I'm having trouble figuring out how to test this but locally here is the before and after output: Parse.y ``` $ ./miniruby --parser=parse.y test.rb "1" ``` Prism Before: ``` $ ./miniruby --parser=prism test.rb "1\n " ``` Prism after: ``` $ ./miniruby --parser=prism test.rb "1" ```
|
I believe that this fixes it but I'm super nervous about it because the fix doesn't make sense... the breakpoint has already been incremented by 1, so it seems like this would specifically move it forward by 3 bytes. Could you test out some other combinations and see if you can reproduce? I can merge otherwise, but I think it merits some more time just because it's such a confusing area of the codebase. |
|
Happy to test more but I'm not sure what else to test, the CRuby parser tests pass locally as do all the Prism tests. It also doesn't break the known cases I came up with more than they are already broken. I also am not super confident in this change other than for the testing I did. |
|
Is this actually a bug in Prism? @eightbitraptor and I were taking a look in to this issue. We'd expect both programs below to evaluate the same: program1 = "%\n1_\r\n\n" # => parse.y: 1_, prism: "1_\n"
program2 = "%'1_\r\n'" # => "1_\n"
p eval(program1)
p eval(program2)Both |
|
We raised this upstream as a Bug in |
|
I guess this fix isn't complete. The problem is that So this program Here is a program to show a more exacerbated issue: def hi
"hello"
end
str = "%\n1\r\n;hi\n"
p eval str, bindingWith It looks like with this patch we still get the wrong value: Honestly, I think we should make a special case for |
|
I don't think we can look for the next If I understand the problem correctly, then in order to implement this right we need to make a special case for |
Ya, that's what I'm toying with right now. It doesn't seem to remove the |
When there is a
\r\nin the following example:p eval "%\n1\r\n \n"Prism was returning"1\n "whereas parse.y returns"1". In this case the cursor needs to be set to the breakpoint (which is\r) plus 2 to ignore the new line and the space.I'm having trouble figuring out how to test this but locally here is the before and after output:
Parse.y
Prism Before:
Prism after:
Fixed example 2 from #3230