Uh oh!
There was an error while loading. Please reload this page.
Add Prism.node_for(Method|UnboundMethod|Proc) to get a Prism node for a callable - #3808
Add Prism.node_for(Method|UnboundMethod|Proc) to get a Prism node for a callable#3808eregon wants to merge 7 commits into
Conversation
tompng
commented
Dec 14, 2025
Looks like Proc generated by |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
dd02f75 to
5d510f5Compareeregon
commented
Dec 14, 2025
The 2.7 failure is quite annoying: https://github.com/ruby/prism/actions/runs/20211767571/job/58018650394?pr=3808 |
Earlopain
commented
Dec 14, 2025
This is something we should probably talk about sometime in the future. It was added for the convenience of rubocop as far as I'm aware and I appreciate that this happened. But I do not want to keep these long EOL versions supported forever. For now I would just put this in a separate file like you said. You shoudl be able to use the version-specific gemfile with |
24bdf87 to
3c0b91cCompareeregon
commented
Dec 14, 2025
@tompng Do you mean: does not have a |
Implemented. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
eregon
commented
Dec 14, 2025
Looking at things like |
966dda3 to
eafdef7CompareI found that {Method,UnboundMethod,Proc}#source_location returns columns in bytes and not in characters. EDIT: It also means |
Uh oh!
There was an error while loading. Please reload this page.
| end_offset = parse_result.source.line_to_byte_offset(end_line) + end_column | ||
| start_byte_column = start_offset - parse_result.source.line_start(start_offset) | ||
| found = root.tunnel(start_line, start_byte_column).reverse.find do |node| |
There was a problem hiding this comment.
rfind would be nice here but of course it's only RUby 4+.
I guess we could do a polyfill but for this case I doubt it matters, most of the time is not spent here but in creating the Ruby objects for the AST, there are typically only a few nodes returned by tunnel.
eregon
commented
Dec 15, 2025
Re the test-all failure, I'll fix it, makes it clear test-unit |
Uh oh!
There was an error while loading. Please reload this page.
Earlopain
commented
Dec 17, 2025
For reference, this won't be available (at least in Ruby 4.0) unfortunately https://bugs.ruby-lang.org/issues/21783#note-8 |
kddnewton
commented
Dec 18, 2025
@eregon we've marked this as blocked until and unless the source location thing gets resolved. Another option is requesting an official node_id API. Is that something you would consider implementing in TruffleRuby? |
eregon
commented
Dec 30, 2025
ruby/ruby#15580 is merged so this is unblocked now :) |
The CI was green before updating to latest CRuby 4.1: https://github.com/ruby/prism/actions/runs/20605030946/attempts/2?pr=3808 Upgrading to sexp_processor-4.17.5 should fix that. |
eregon
commented
Dec 31, 2025
Green now |
kddnewton
commented
Jan 6, 2026
The code looks largely fine, but it's not clear to me that this feature is actually sticking around, based on the discussions on the issue tracker. Let's wait until that's resolved. |
eregon
commented
Jan 6, 2026
Which discussion are you thinking to? |
FWIW I do plan to comment on https://bugs.ruby-lang.org/issues/21795 (sounds great to me). |
… a callable * See https://bugs.ruby-lang.org/issues/21005 and https://bugs.ruby-lang.org/issues/20999 * Stub source_location for older Rubies in NodeForTest. * Move out the inline method definition for Ruby 2.7.
* By comparing byte offsets which folds 3 branches into 1. * Also avoids allocation of Location objects.
and https://bugs.ruby-lang.org/issues/20999