Add failing test for define_singleton_method #38
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It turns out when using dynamically defining methods via
define_method
anddefine_singleton_method
, the call stack is inconsistent compared with how pre-defined Ruby methods look.On
:call
events, the frame points to where the method is received in Ruby, i.e. the block passed todefine_method
ordefine_singleton_method
. This is the expected behaviour for Ruby invocations:But, when the
:return
event fires, instead of pointing to the end of the method definition like a normal ruby method, it points one frame up the stack, to where the originalcaller
occurred. Since we assume Ruby methods point one level deeper, Rotoscope pops the frame one level further, and points to where the caller's caller came from. This means thecall
andreturn
events won't match up.I tried to figure out how to get around this one (by using Ruby's bitmasks to determine if it was a dynamically defined method, etc.), but I've been unsuccessful thus far. As a compromise, I've added a failing test case with a
skip
, just to be able to replicate the problem.This problem is currently avoidable via
flatten: true
, since unmatched returns are ignored.bin/fmt
was successfully run