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

Fix irb-1.9.0 crash on {}. completion #764

Merged
merged 1 commit into from
Nov 18, 2023

Conversation

tompng
Copy link
Member

@tompng tompng commented Nov 16, 2023

Fix IRB crash when showing document of {}.

In RegexpCompletor, doc_namespace of {}. will return an array ["Proc.#{message}", "Hash.#{message}"]
When name = doc_namespace.call(result[pointer]) is not a String nor nil, IRB crashes.

Change to use the first namespaces. This will fix a bug that document of {}. was not shown from the beginning(irb 1.4.0,
first version that implements autocomplete and document dialog).

I also changed the order of Hash and Proc because Hash is more important to show in document dialog.

Reproduce

Run irb with irb -f
Type {}.
Press TAB key

$ irb -f
irb(main):001> {}.parameters/Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb/input-method.rb:315:in `block in show_doc_dialog_proc': undefined method `match?' for ["Proc.parameters", "Hash.parameters"]:Array (NoMethodError)         }.parameters                     ▀
                }.hash                            
        show_easter_egg = name&.match?(/\ARubyVM/) && !ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
                              ^^^^^^^^            
        from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:588:in `instance_exec'
        from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:588:in `call'
        from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:623:in `call'
        from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:776:in `update_each_dialog'
        from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:652:in `block in render_dialog'
        from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:650:in `map'
        from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:650:in `render_dialog'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/line_editor.rb:500:in `rerender'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:351:in `block (3 levels) in inner_readline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:349:in `each'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:349:in `block (2 levels) in inner_readline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:424:in `block in read_io'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:394:in `loop'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:394:in `read_io'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:347:in `block in inner_readline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:345:in `loop'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:345:in `inner_readline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:273:in `block in readmultiline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/ansi.rb:152:in `block in with_raw_input'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/ansi.rb:152:in `raw'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline/ansi.rb:152:in `with_raw_input'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/reline-0.4.0/lib/reline.rb:269:in `readmultiline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/3.2.0/forwardable.rb:240:in `readmultiline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb/input-method.rb:449:in `gets'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:539:in `block in read_input'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:823:in `signal_status'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:537:in `read_input'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:559:in `readmultiline'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:586:in `block in each_top_level_statement'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:585:in `loop'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:585:in `each_top_level_statement'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:507:in `eval_input'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:494:in `block in run'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:493:in `catch'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:493:in `run'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/lib/irb.rb:395:in `start'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.9.0/exe/irb:9:in `<top (required)>'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/bin/irb:25:in `load'
	from /Users/tomoya.ishida/.rbenv/versions/3.2.2/bin/irb:25:in `<main>'

@tompng tompng changed the title Fix irb crash on {}. completion Fix irb-1.9.0 crash on {}. completion Nov 18, 2023
@tompng tompng merged commit 07e4d54 into ruby:master Nov 18, 2023
24 checks passed
@tompng tompng deleted the fix_irb_crash_in_easteregg_check branch November 18, 2023 17:49
matzbot pushed a commit to ruby/ruby that referenced this pull request Nov 18, 2023
@tompng tompng mentioned this pull request Nov 20, 2023
@st0012 st0012 added the bug Something isn't working label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

3 participants