1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Prohibit setter method names in endless method definition

https://bugs.ruby-lang.org/issues/16746#note-26
This commit is contained in:
Yusuke Endoh 2020-08-31 16:49:16 +09:00
parent 86737c509c
commit 53ba9fb74e
Notes: git 2020-08-31 20:30:52 +09:00
2 changed files with 4 additions and 0 deletions

View file

@ -2474,6 +2474,9 @@ arg : lhs '=' arg_rhs
}
| defn_head f_paren_args '=' arg
{
if (is_attrset_id($<node>1->nd_mid)) {
yyerror1(&@1, "setter method cannot be defined in an endless method definition");
}
token_info_drop(p, "def", @1.beg_pos);
restore_defun(p, $<node>1->nd_defn);
/*%%%*/

View file

@ -1429,6 +1429,7 @@ eom
end
assert_equal("class ok", k.rescued("ok"))
assert_equal("instance ok", k.new.rescued("ok"))
assert_syntax_error('def foo=() = 42', /setter method cannot be defined in an endless method definition/)
end
def test_methoddef_in_cond