summaryrefslogtreecommitdiff
path: root/lib/irb/cmd
diff options
context:
space:
mode:
authorStan Lo <stan001212@gmail.com>2024-02-13 13:36:29 +0000
committergit <svn-admin@ruby-lang.org>2024-02-13 13:36:32 +0000
commit2f0f95235a1de489f50c7a9dbe3477f9f7e60cd1 (patch)
tree9708ab201cc13b3714ba9a00b158d18cc3e6feef /lib/irb/cmd
parentec26786b1a37350c0ff21666b028ec5e2aa6a318 (diff)
[ruby/irb] Fix SourceFinder's constant evaluation issue
(https://github.com/ruby/irb/pull/869) Currently, if the signature's constant part is not defined, a NameError would be raised. ``` irb(main):001> show_source Foo (eval):1:in `<top (required)>': uninitialized constant Foo (NameError) Foo ^^^ from (irb):1:in `<main>' ``` This commit fixes the issue and simplifies the `edit` command's implementation. https://github.com/ruby/irb/commit/8c16e029d1
Diffstat (limited to 'lib/irb/cmd')
-rw-r--r--lib/irb/cmd/edit.rb8
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/irb/cmd/edit.rb b/lib/irb/cmd/edit.rb
index 2f89f83ecc..dae65f3c39 100644
--- a/lib/irb/cmd/edit.rb
+++ b/lib/irb/cmd/edit.rb
@@ -27,13 +27,7 @@ module IRB
if path.nil?
path = @irb_context.irb_path
elsif !File.exist?(path)
- source =
- begin
- SourceFinder.new(@irb_context).find_source(path)
- rescue NameError
- # if user enters a path that doesn't exist, it'll cause NameError when passed here because find_source would try to evaluate it as well
- # in this case, we should just ignore the error
- end
+ source = SourceFinder.new(@irb_context).find_source(path)
if source&.file_exist? && !source.binary_file?
path = source.file