Skip to content

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

Merged
tompng merged 1 commit intoruby: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 intoruby:masterfrom
tompng:fix_ctrl_char_string

Conversation

@tompng
Copy link
Member

@tompng tompng commented Mar 11, 2026

Workaround for ruby/prism#3987

@tompng
Copy link
Member Author

tompng commented Mar 11, 2026

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants