diff --git a/lib/irb/nesting_parser.rb b/lib/irb/nesting_parser.rb index 05ef152c9..dfa235582 100644 --- a/lib/irb/nesting_parser.rb +++ b/lib/irb/nesting_parser.rb @@ -222,6 +222,7 @@ def heredoc_string_like(node, type) # Heredoc closing contains trailing newline. We need to exclude it close_location_start(node.closing_loc) if node.closing_loc && !node.closing.empty? elsif node.opening + return if node.opening == '?' && node.closing.nil? # Character literal has no closing open_location(node.location, type, node.opening) if node.closing && node.closing != '' # Closing of `"#{\n` is "\n". We need to treat it as not-closed. diff --git a/test/irb/test_nesting_parser.rb b/test/irb/test_nesting_parser.rb index cf4082609..91ea8cd90 100644 --- a/test/irb/test_nesting_parser.rb +++ b/test/irb/test_nesting_parser.rb @@ -347,5 +347,15 @@ def test_case_in assert_equal(['in'], next_opens.map(&:tok)) end end + + def test_char_literal + code = <<~EOS + ?a + EOS + prev_opens, next_opens, min_depth = parse_by_line(code).last + assert_equal([], prev_opens) + assert_equal([], next_opens) + assert_equal(0, min_depth) + end end end