Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Trivial
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.7.0.RC1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
set_trace_func(proc{ |event, file, line, method, binding, klass|
puts binding.eval("[self, s]").inspect if event == "raise"
})
def hello
s = "snorkle"
s.desnrok
end
hello
# output:
# ["snorkle", "snorkle"]
# NoMethodError: undefined method `desnrok' for "snorkle":String
# hello at a.rb:7
# (root) at a.rb +10
Both 's' and 'self' are "snorkle" — 'self' in this case should be main.
I'm bringing this up because I encountered the same problem when calling ThreadContext#currentBinding() in interception: https://github.com/ConradIrwin/interception/blob/master/ext/org/pryrepl/InterceptionEventHook.java
In this case the problem could be fixed by using ThreadContext#previousBinding(), but I'm unable to decide at runtime which one should be used (always using previousBinding() causes other cases to fail).
The promising looking ThreadContext#getCurrentRubyFrame() seems to not help as it is the same as ThreadContext#currentFrame().
Weird.