Skip to content

Fix IRB crash when typing string literal with control/meta sequence#1182

Merged
tompng merged 1 commit into
ruby:masterfrom
tompng:fix_ctrl_char_string
Mar 11, 2026
Merged

Fix IRB crash when typing string literal with control/meta sequence#1182
tompng merged 1 commit into
ruby:masterfrom
tompng:fix_ctrl_char_string

Conversation

@tompng

@tompng tompng commented Mar 11, 2026

Copy link
Copy Markdown
Member

Workaround for ruby/prism#3987

@tompng

tompng commented Mar 11, 2026

Copy link
Copy Markdown
Member Author

Even with this workaround, IRB crashes with this input

irb(main):001" "\C-
irb(main):002" \M-

because colorize fails

IRB::Color.colorize_code "\"\\C-\n\\M-"
__END__
/Users/tomoya.ishida/.rbenv/versions/4.0.0/lib/ruby/gems/4.0.0/gems/reline-0.6.3/lib/reline/unicode.rb:45:in 'Reline::Unicode.escape_for_print': undefined method 'chars' for nil (NoMethodError)

    str.chars.map! { |gr|
       ^^^^^^
	from /Users/tomoya.ishida/github/ruby/irb/lib/irb/color.rb:193:in 'block (2 levels) in IRB::Color.colorize_code'
	from /Users/tomoya.ishida/github/ruby/irb/lib/irb/color.rb:192:in 'Range#each'
	from /Users/tomoya.ishida/github/ruby/irb/lib/irb/color.rb:192:in 'block in IRB::Color.colorize_code'
	from /Users/tomoya.ishida/github/ruby/irb/lib/irb/color.rb:226:in 'IRB::Color.colorize_code'
	from -:1:in '<main>'
@st0012 st0012 added the bug Something isn't working label Mar 11, 2026
@tompng tompng merged commit 209bcf7 into ruby:master Mar 11, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

2 participants