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

parse.y: handle "duplicated argument name" appropriately on ripper.y

refs: 733ed1e184
This commit is contained in:
Nobuhiro IMAI 2021-01-09 12:18:14 +09:00 committed by Nobuyoshi Nakada
parent 1a3343cfdc
commit 7ff0e93f96
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 5 additions and 2 deletions

View file

@ -7871,7 +7871,9 @@ formal_argument(struct parser_params *p, ID lhs)
formal_argument(struct parser_params *p, VALUE lhs)
#endif
{
switch (id_type(get_id(lhs))) {
ID id = get_id(lhs);
switch (id_type(id)) {
case ID_LOCAL:
break;
#ifndef RIPPER
@ -7896,7 +7898,7 @@ formal_argument(struct parser_params *p, VALUE lhs)
return 0;
#undef ERR
}
shadowing_lvar(p, lhs);
shadowing_lvar(p, id);
return lhs;
}

View file

@ -148,6 +148,7 @@ class TestRipper::Lexer < Test::Unit::TestCase
BAD_CODE = [
[:parse_error, 'def req(true) end', %r[unexpected `true'], 'true'],
[:parse_error, 'def req(a, a) end', %r[duplicated argument name], 'a'],
[:assign_error, 'begin; nil = 1; end', %r[assign to nil], 'nil'],
[:alias_error, 'begin; alias $x $1; end', %r[number variables], '$1'],
[:class_name_error, 'class bad; end', %r[class/module name], 'bad'],