Skip to content

Commit

Permalink
Fix segv when parsing command by ripper
Browse files Browse the repository at this point in the history
89cfc15 made this event dispatch to pass `Qundef`
to user defined callback method by mistake.
This commit fix it to be `nil`.
  • Loading branch information
yui-knk committed Apr 11, 2024
1 parent 38e3819 commit 39be11a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parse.y
Expand Up @@ -3447,7 +3447,7 @@ command : fcall command_args %prec tLOWEST
{
set_embraced_location($5, &@4, &@6);
$$ = new_command_qcall(p, idCOLON2, $1, $3, Qnull, $5, &@3, &@$);
/*% ripper: method_add_block!(command_call!($:1, $:2, $:3, Qundef), $:5) %*/
/*% ripper: method_add_block!(command_call!($:1, $:2, $:3, Qnil), $:5) %*/
}
| keyword_super command_args
{
Expand Down
15 changes: 15 additions & 0 deletions test/ripper/test_sexp.rb
Expand Up @@ -123,6 +123,21 @@ def test_named_with_default
assert_equal(exp, named)
end

def test_command
sexp = Ripper.sexp("a::C {}")
assert_equal(
[:program,
[
[:method_add_block,
[:command_call,
[:vcall, [:@ident, "a", [1, 0]]],
[:@op, "::", [1, 1]],
[:@const, "C", [1, 3]],
nil],
[:brace_block, nil, [[:void_stmt]]]]]],
sexp)
end

def search_sexp(sym, sexp)
return sexp if !sexp or sexp[0] == sym
sexp.find do |e|
Expand Down

0 comments on commit 39be11a

Please sign in to comment.