mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: duplicated kwrest name
* parse.y (f_kwrest): reject duplicated kwrest argument name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
86c0eae56e
commit
38da1a5398
3 changed files with 57 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Jan 7 15:31:58 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (f_kwrest): reject duplicated kwrest argument name.
|
||||
|
||||
Mon Jan 7 15:24:10 2013 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm_trace.c (rb_threadptr_exec_event_hooks_orig): pop tag before
|
||||
|
|
1
parse.y
1
parse.y
|
@ -4682,6 +4682,7 @@ kwrest_mark : tPOW
|
|||
|
||||
f_kwrest : kwrest_mark tIDENTIFIER
|
||||
{
|
||||
shadowing_lvar(get_id($2));
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
|
|
@ -133,6 +133,58 @@ class TestSyntax < Test::Unit::TestCase
|
|||
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){
|
||||
|
|
Loading…
Reference in a new issue