[前][次][番号順一覧][スレッド一覧]

ruby-changes:64803

From: Nobuhiro <ko1@a...>
Date: Sat, 9 Jan 2021 13:33:55 +0900 (JST)
Subject: [ruby-changes:64803] 7ff0e93f96 (master): parse.y: handle "duplicated argument name" appropriately on ripper.y

https://git.ruby-lang.org/ruby.git/commit/?id=7ff0e93f96

From 7ff0e93f96cc55467d791ebc841f12f9130bf181 Mon Sep 17 00:00:00 2001
From: Nobuhiro IMAI <nov@y...>
Date: Sat, 9 Jan 2021 12:18:14 +0900
Subject: parse.y: handle "duplicated argument name" appropriately on ripper.y

refs: 733ed1e184

diff --git a/parse.y b/parse.y
index ff00fa8..cdd64f7 100644
--- a/parse.y
+++ b/parse.y
@@ -7871,7 +7871,9 @@ formal_argument(struct parser_params *p, ID lhs) https://github.com/ruby/ruby/blob/trunk/parse.y#L7871
 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) https://github.com/ruby/ruby/blob/trunk/parse.y#L7898
 	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 f8e751d..9762478 100644
--- a/test/ripper/test_lexer.rb
+++ b/test/ripper/test_lexer.rb
@@ -148,6 +148,7 @@ class TestRipper::Lexer < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ripper/test_lexer.rb#L148
 
   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'],
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]