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

Ripper comparison operators #6548

Closed
kddnewton opened this issue Feb 2, 2021 · 1 comment
Closed

Ripper comparison operators #6548

kddnewton opened this issue Feb 2, 2021 · 1 comment

Comments

@kddnewton
Copy link

Environment Information

jruby 9.2.14.0 (2.5.7) 2020-12-08 ebe64ba OpenJDK 64-Bit Server VM 25.265-b01 on 1.8.0_265-b01 +jit [darwin-x86_64]
Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

Expected Behavior

ruby -rripper -e 'pp Ripper.sexp("1 < 2")'

On CRuby

[:program, [[:binary, [:@int, "1", [1, 0]], :<, [:@int, "2", [1, 4]]]]]

Actual Behavior

On JRuby:

[:program,
 [[:binary, [:@int, "1", [1, 0]], [:@op, "<", [1, 2]], [:@int, "2", [1, 4]]]]]

Note the difference is the comparison operator gets reported as an @op node, whereas on CRuby it's just a Symbol. Interestingly, if you change it to 1 + 2, it'll be a Symbol.

@headius
Copy link
Member

headius commented Feb 2, 2021

Confirmed on Ruby 2.5.8 and JRuby 9.2 HEAD.

@headius headius added this to the JRuby 9.2.15.0 milestone Feb 2, 2021
enebo added a commit that referenced this issue Feb 23, 2021
<, >, <=, and >= were not returning interned string values like all
other binary operations.  Changed to make them match.

Bonus fix!  dsym was using xstrings instead of strings (MRI parser
does this).  Matched up.
@enebo enebo closed this as completed Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants