Skip to content

Conversation

@eregon
Copy link
Member

@eregon eregon commented Jan 29, 2026

@eregon eregon requested review from Earlopain and kddnewton January 29, 2026 19:41
@eregon eregon force-pushed the ripper-sexp-coerce branch from 5bbfbcf to 6e1d9e9 Compare January 29, 2026 19:52
Copy link
Collaborator

@Earlopain Earlopain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the rules are a bit more complex: https://github.com/ruby/ruby/blob/acc414572c213f2690eee56bac3d2355a24e5930/ext/ripper/ripper_init.c.tmpl#L357-L376

Do you want to implement those also? File should be easy at least.

def test_sexp_coercion
string_like = Object.new
def string_like.to_str; "a"; end
assert_equal [:program, [[:vcall, [:@ident, "a", [1, 0]]]]], Translation::Ripper.sexp(string_like)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really matter what the result is, we just want the same behaviour as native

Suggested change
assert_equal [:program, [[:vcall, [:@ident, "a", [1, 0]]]]], Translation::Ripper.sexp(string_like)
assert_equal Ripper.sexp(string_like), Translation::Ripper.sexp(string_like)

@eregon
Copy link
Member Author

eregon commented Jan 29, 2026

It looks like the rules are a bit more complex: https://github.com/ruby/ruby/blob/acc414572c213f2690eee56bac3d2355a24e5930/ext/ripper/ripper_init.c.tmpl#L357-L376

Do you want to implement those also? File should be easy at least.

I see. If you want to do it feel free to push to this branch, otherwise I can get to it tomorrow or so.

@Earlopain
Copy link
Collaborator

Tomorrow is fine

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

Successfully merging this pull request may close these issues.

2 participants