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

Thread::Backtrace::Location#label/base_label incompatible with MRI top level description #5790

Open
piotrmurach opened this issue Jul 14, 2019 · 2 comments

Comments

@piotrmurach
Copy link

commented Jul 14, 2019

Environment

Expected Behavior

Expect JRuby label and base_label to match MRI behaviour.

Actual Behavior

The Thread::Backtrace::Location#label when referring to top-level scope returns "<main>" as the method description. In comparison the CRuby/MRI returns "<top (required)>" for both #label and #base_label.

@headius

This comment has been minimized.

Copy link
Member

commented Jul 15, 2019

Aha... the (required) in that string refers to the fact that this is a file loaded via a require (or a load?) rather than being the actual "main" file.

For a target "main" script, the result is actually the same as JRuby:

$ rvm ruby-2.5.3 do ruby -e 'p caller(0, 1)'
["-e:1:in `<main>'"]

So we won't be changing main to top...but we need to have a different way to identify the top frame for required (versus directly executed) scripts.

@headius

This comment has been minimized.

Copy link
Member

commented Jul 15, 2019

Ok, I won't have time to work on this right now, but here's what needs to happen:

  • The "" comes from Interpreter.java and this is likely the place we need to add support for a different top-level frame name.
  • The logic here gets called via IRTranslator.java from four places in Ruby.java.
  • Those four places are themselves called from either the "main" startup logic or from the "load" paths used during load/require.

I believe this is the path that needs additional smarts for when the target script is running as a load/require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.