зеркало из https://github.com/github/ruby.git
ripper: wrap endless method in bodystmt [Bug #17869]
This commit is contained in:
Родитель
050bb06e66
Коммит
50a534a152
16
parse.y
16
parse.y
|
@ -1636,6 +1636,7 @@ command_asgn : lhs '=' lex_ctxt command_rhs
|
|||
/*%%%*/
|
||||
$$ = set_defun_body(p, $1, $2, $4, &@$);
|
||||
/*% %*/
|
||||
/*% ripper[$4]: bodystmt!($4, Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: def!(get_value($1), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
|
@ -1647,7 +1648,8 @@ command_asgn : lhs '=' lex_ctxt command_rhs
|
|||
$4 = rescued_expr(p, $4, $6, &@4, &@5, &@6);
|
||||
$$ = set_defun_body(p, $1, $2, $4, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: def!(get_value($1), $2, rescue_mod!($4, $6)) %*/
|
||||
/*% ripper[$4]: bodystmt!(rescue_mod!($4, $6), Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: def!(get_value($1), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
| defs_head f_opt_paren_args '=' command
|
||||
|
@ -1659,6 +1661,7 @@ command_asgn : lhs '=' lex_ctxt command_rhs
|
|||
/*%
|
||||
$1 = get_value($1);
|
||||
%*/
|
||||
/*% ripper[$4]: bodystmt!($4, Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
|
@ -1672,7 +1675,8 @@ command_asgn : lhs '=' lex_ctxt command_rhs
|
|||
/*%
|
||||
$1 = get_value($1);
|
||||
%*/
|
||||
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, rescue_mod!($4, $6)) %*/
|
||||
/*% ripper[$4]: bodystmt!(rescue_mod!($4, $6), Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
| backref tOP_ASGN lex_ctxt command_rhs
|
||||
|
@ -2557,6 +2561,7 @@ arg : lhs '=' lex_ctxt arg_rhs
|
|||
/*%%%*/
|
||||
$$ = set_defun_body(p, $1, $2, $4, &@$);
|
||||
/*% %*/
|
||||
/*% ripper[$4]: bodystmt!($4, Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: def!(get_value($1), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
|
@ -2568,7 +2573,8 @@ arg : lhs '=' lex_ctxt arg_rhs
|
|||
$4 = rescued_expr(p, $4, $6, &@4, &@5, &@6);
|
||||
$$ = set_defun_body(p, $1, $2, $4, &@$);
|
||||
/*% %*/
|
||||
/*% ripper: def!(get_value($1), $2, rescue_mod!($4, $6)) %*/
|
||||
/*% ripper[$4]: bodystmt!(rescue_mod!($4, $6), Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: def!(get_value($1), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
| defs_head f_opt_paren_args '=' arg
|
||||
|
@ -2580,6 +2586,7 @@ arg : lhs '=' lex_ctxt arg_rhs
|
|||
/*%
|
||||
$1 = get_value($1);
|
||||
%*/
|
||||
/*% ripper[$4]: bodystmt!($4, Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
|
@ -2593,7 +2600,8 @@ arg : lhs '=' lex_ctxt arg_rhs
|
|||
/*%
|
||||
$1 = get_value($1);
|
||||
%*/
|
||||
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, rescue_mod!($4, $6)) %*/
|
||||
/*% ripper[$4]: bodystmt!(rescue_mod!($4, $6), Qnil, Qnil, Qnil) %*/
|
||||
/*% ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, $4) %*/
|
||||
local_pop(p);
|
||||
}
|
||||
| primary
|
||||
|
|
|
@ -672,12 +672,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
|
|||
thru = {}
|
||||
tree = parse('def foo() = 42', events, &hook)
|
||||
assert_equal({on_def: true}, thru)
|
||||
assert_equal '[def(foo,[],42)]', tree
|
||||
assert_equal '[def(foo,[],bodystmt(42))]', tree
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo() = 42 rescue 0', events, &hook)
|
||||
assert_equal({on_def: true}, thru)
|
||||
assert_equal '[def(foo,[],rescue_mod(42,0))]', tree
|
||||
assert_equal '[def(foo,[],bodystmt(rescue_mod(42,0)))]', tree
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo=() = 42', events, &hook)
|
||||
|
@ -686,6 +686,16 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
|
|||
thru = {}
|
||||
tree = parse('def foo=() = 42 rescue 0', events, &hook)
|
||||
assert_equal({on_def: true, on_parse_error: true}, thru)
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo() = p 42', events, &hook)
|
||||
assert_equal({on_def: true}, thru)
|
||||
assert_equal '[def(foo,[],bodystmt(command(p,[42])))]', tree
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo() = p 42 rescue 0', events, &hook)
|
||||
assert_equal({on_def: true}, thru)
|
||||
assert_equal '[def(foo,[],bodystmt(rescue_mod(command(p,[42]),0)))]', tree
|
||||
end
|
||||
|
||||
def test_defined
|
||||
|
@ -713,12 +723,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
|
|||
thru = {}
|
||||
tree = parse('def foo.bar() = 42', events, &hook)
|
||||
assert_equal({on_defs: true}, thru)
|
||||
assert_equal '[defs(vcall(foo),.,bar,[],42)]', tree
|
||||
assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(42))]', tree
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo.bar() = 42 rescue 0', events, &hook)
|
||||
assert_equal({on_defs: true}, thru)
|
||||
assert_equal '[defs(vcall(foo),.,bar,[],rescue_mod(42,0))]', tree
|
||||
assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(rescue_mod(42,0)))]', tree
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo.bar=() = 42', events, &hook)
|
||||
|
@ -727,6 +737,16 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
|
|||
thru = {}
|
||||
tree = parse('def foo.bar=() = 42 rescue 0', events, &hook)
|
||||
assert_equal({on_defs: true, on_parse_error: true}, thru)
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo.bar() = p 42', events, &hook)
|
||||
assert_equal({on_defs: true}, thru)
|
||||
assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(command(p,[42])))]', tree
|
||||
|
||||
thru = {}
|
||||
tree = parse('def foo.bar() = p 42 rescue 0', events, &hook)
|
||||
assert_equal({on_defs: true}, thru)
|
||||
assert_equal '[defs(vcall(foo),.,bar,[],bodystmt(rescue_mod(command(p,[42]),0)))]', tree
|
||||
end
|
||||
|
||||
def test_do_block
|
||||
|
|
Загрузка…
Ссылка в новой задаче