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

Opening a class body doesn't reset the value of __method__ #1402

Closed
rf- opened this issue Jan 14, 2014 · 4 comments
Closed

Opening a class body doesn't reset the value of __method__ #1402

rf- opened this issue Jan 14, 2014 · 4 comments
Milestone

Comments

@rf-
Copy link

@rf- rf- commented Jan 14, 2014

def foo
  eval "class Bar; p __method__; end"
end

foo

On MRI 2.0.0 and 1.9.3, this prints nil. On JRuby 1.7.9, it prints :foo.

Obviously this is kind of a crazy edge case, but it does cause problems for Pry.

@headius
Copy link
Member

@headius headius commented Jan 14, 2014

Oh Pry, you so crazy.

@headius
Copy link
Member

@headius headius commented Jan 14, 2014

It appears we have never set a method name on the current frame for class and module bodies. When entering a class or module, we simply clone the previous call's frame and do not clear the name therein. That causes method, callee, caller, and others to show the outer method's name.

I believe this is special-cased logic, however. Kernel#caller does show a name, albeit one appropriate to a class:

 $ rvm ruby-2.1 do ruby -e "class Foo; p caller(0)[0]; end"
"-e:1:in `<class:Foo>'"

The fact that method and callee return nil indicates they're specializing that logic for when the surrounding frame is a class.

@headius headius closed this in a049d87 Jan 14, 2014
@BanzaiMan
Copy link
Member

@BanzaiMan BanzaiMan commented Jan 16, 2014

@headius this fix broke master and jruby-1_7.

@BanzaiMan BanzaiMan reopened this Jan 16, 2014
@headius
Copy link
Member

@headius headius commented Jan 17, 2014

The issue was a bad test in test_trace_func. It didn't pass on MRI either. 3e5496f

@headius headius closed this Jan 17, 2014
@enebo enebo added this to the JRuby 1.7.11 milestone Feb 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants