diff options
author | James Coleman <jtc331@gmail.com> | 2022-04-07 14:51:38 -0400 |
---|---|---|
committer | jcoleman <jtc331@gmail.com> | 2022-04-09 15:30:52 -0400 |
commit | 9f5fdd31da5a7f43c85b463dde0fe83774f7f4c4 (patch) | |
tree | 678e0545cdac47f18512e73413ad800725915c45 /lib | |
parent | 0e03ed65056a242b14add00fc9c53640180f2194 (diff) | |
download | pry-9f5fdd31da5a7f43c85b463dde0fe83774f7f4c4.tar.gz |
Weird method location shouldn't match unknown location
Methods that don't have a source location (e.g., C methods, or methods
created via metaprogramming or even `alias_method` to C methods) are not
reasonable possible matching methods for a "weird method" we need to
locate.
In this case `renamed_method_source_location` can also return `nil` if
the actual code in question is a bare script (i.e., no methods). If that
script is loaded via `eval` then we'll end up in the weird method path
in the first place, but no method matching can be found, and if a
no-source-location method exists, we'll return that.
Down the line that's particularly painful because the source loading
thinks it's a C method, but it can actually be from metaprogramming (and
`alias_method`!), and then `Pry::Method#pry_doc_info` raises an error,
and `wherami` breaks even though we already have valid `__FILE__` and
`__LINE__` values.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pry/method/weird_method_locator.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pry/method/weird_method_locator.rb b/lib/pry/method/weird_method_locator.rb index e4f58c8f..85614aec 100644 --- a/lib/pry/method/weird_method_locator.rb +++ b/lib/pry/method/weird_method_locator.rb @@ -158,7 +158,7 @@ class Pry alias_name = all_methods_for(target_self).find do |v| location = target_self.method(v).source_location - expanded_source_location(location) == renamed_method_source_location + location && expanded_source_location(location) == renamed_method_source_location end alias_name && Pry::Method(target_self.method(alias_name)) |