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

const_source_location returning empty values where MRI does not #2833

Closed
nirvdrum opened this issue Jan 17, 2023 · 2 comments · Fixed by #2835
Closed

const_source_location returning empty values where MRI does not #2833

nirvdrum opened this issue Jan 17, 2023 · 2 comments · Fixed by #2835

Comments

@nirvdrum
Copy link
Collaborator

I'm running into an issue booting Sorbet. It uses const_source_location to build up a path to the lib directory. This works fine on MRI as it returns the filename defining the module whereas TruffleRuby returns [].

I've narrowed down the TruffleRuby issue to a simple reproduction (placed in a file named bad.rb):

module T
  module Private
  end
end

puts T.const_source_location(:Private)

On MRI, I get:

> ruby -v bad.rb
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin21]
bad.rb
2

On TruffleRuby, I get:

> jt ruby -v bad.rb
truffleruby 23.0.0-dev-71f07786*, like ruby 3.1.3, GraalVM CE JVM [aarch64-darwin]

I've looked at the issue briefly and it's due to the constants not having associated source sections. In that case, we have const_source_location return [].

@eregon
Copy link
Member

eregon commented Jan 18, 2023

This is an easy fix (#2835), interestingly we already recorded the SourceSection on RubyModule itself for interop, which is something Ruby doesn't have a way to query, but we missed to pass a node/SourceSection to setConstantInternal().

@nirvdrum
Copy link
Collaborator Author

Great. I was planning to pick this one up. I was hoping it was easy, but feared it might require parser changes.

@eregon eregon added this to the 23.0.0 Release milestone Jan 20, 2023
nirvdrum pushed a commit to Shopify/truffleruby that referenced this issue Jan 30, 2023
sophie-kaleba pushed a commit to sophie-kaleba/truffleruby that referenced this issue Feb 16, 2023
sophie-kaleba pushed a commit to sophie-kaleba/truffleruby that referenced this issue Feb 16, 2023
john-heinnickel pushed a commit to thermofisher-jch/truffleruby that referenced this issue Aug 16, 2023
sophie-kaleba pushed a commit to sophie-kaleba/truffleruby that referenced this issue Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants