summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuhiro IMAI <nov@yo.rim.or.jp>2021-01-09 12:18:14 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-09 13:33:33 +0900
commit7ff0e93f96cc55467d791ebc841f12f9130bf181 (patch)
tree652c6f7f4c7e0439ede65ce17ac8b5c7c8bcfc6c
parent1a3343cfdcb765b94bf63375d45618130d6b92c9 (diff)
parse.y: handle "duplicated argument name" appropriately on ripper.y
refs: 733ed1e184
-rw-r--r--parse.y6
-rw-r--r--test/ripper/test_lexer.rb1
2 files changed, 5 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index ff00fa8e35..cdd64f7071 100644
--- a/parse.y
+++ b/parse.y
@@ -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;
}
diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb
index f8e751da53..9762478c62 100644
--- a/test/ripper/test_lexer.rb
+++ b/test/ripper/test_lexer.rb
@@ -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'],