ruby-changes:26673
From: nobu <ko1@a...>
Date: Mon, 7 Jan 2013 15:32:10 +0900 (JST)
Subject: [ruby-changes:26673] nobu:r38724 (trunk): parse.y: duplicated kwrest name
nobu 2013-01-07 15:32:01 +0900 (Mon, 07 Jan 2013) New Revision: 38724 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38724 Log: parse.y: duplicated kwrest name * parse.y (f_kwrest): reject duplicated kwrest argument name. Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_syntax.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38723) +++ ChangeLog (revision 38724) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jan 7 15:31:58 2013 Nobuyoshi Nakada <nobu@r...> + + * parse.y (f_kwrest): reject duplicated kwrest argument name. + Mon Jan 7 15:24:10 2013 Koichi Sasada <ko1@a...> * vm_trace.c (rb_threadptr_exec_event_hooks_orig): pop tag before Index: parse.y =================================================================== --- parse.y (revision 38723) +++ parse.y (revision 38724) @@ -4682,6 +4682,7 @@ kwrest_mark : tPOW https://github.com/ruby/ruby/blob/trunk/parse.y#L4682 f_kwrest : kwrest_mark tIDENTIFIER { + shadowing_lvar(get_id($2)); $$ = $2; } ; Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 38723) +++ test/ruby/test_syntax.rb (revision 38724) @@ -133,6 +133,58 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L133 assert_not_label(:foo, 'class Foo < not_label:foo; end', bug6347) end + def test_duplicated_arg + assert_syntax_error("def foo(a, a) end", /duplicated argument name/) + end + + def test_duplicated_rest + assert_syntax_error("def foo(a, *a) end", /duplicated argument name/) + end + + def test_duplicated_opt + assert_syntax_error("def foo(a, a=1) end", /duplicated argument name/) + end + + def test_duplicated_opt_rest + assert_syntax_error("def foo(a=1, *a) end", /duplicated argument name/) + end + + def test_duplicated_rest_opt + assert_syntax_error("def foo(*a, a=1) end", /duplicated argument name/) + end + + def test_duplicated_rest_post + assert_syntax_error("def foo(*a, a) end", /duplicated argument name/) + end + + def test_duplicated_opt_post + assert_syntax_error("def foo(a=1, a) end", /duplicated argument name/) + end + + def test_duplicated_kw + assert_syntax_error("def foo(a, a: 1) end", /duplicated argument name/) + end + + def test_duplicated_rest_kw + assert_syntax_error("def foo(*a, a: 1) end", /duplicated argument name/) + end + + def test_duplicated_opt_kw + assert_syntax_error("def foo(a=1, a: 1) end", /duplicated argument name/) + end + + def test_duplicated_kw_kwrest + assert_syntax_error("def foo(a: 1, **a) end", /duplicated argument name/) + end + + def test_duplicated_rest_kwrest + assert_syntax_error("def foo(*a, **a) end", /duplicated argument name/) + end + + def test_duplicated_opt_kwrest + assert_syntax_error("def foo(a=1, **a) end", /duplicated argument name/) + end + def test_duplicated_when w = 'warning: duplicated when clause is ignored' assert_warning(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/