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

parse.y: bare kwrest_mark

* parse.y (f_kwrest): allow bare kwrest_mark as valid syntax.  its
  semantics is still undefined.  [Bug #7662] [ruby-core:51269]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-01-07 06:42:13 +00:00
parent 38da1a5398
commit e489dc1ff4
3 changed files with 17 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Mon Jan 7 15:42:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (f_kwrest): allow bare kwrest_mark as valid syntax. its
semantics is still undefined. [Bug #7662] [ruby-core:51269]
Mon Jan 7 15:31:58 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (f_kwrest): reject duplicated kwrest argument name.

View file

@ -4685,6 +4685,10 @@ f_kwrest : kwrest_mark tIDENTIFIER
shadowing_lvar(get_id($2));
$$ = $2;
}
| kwrest_mark
{
$$ = internal_id();
}
;
f_opt : tIDENTIFIER '=' arg_value

View file

@ -1,4 +1,5 @@
require 'test/unit'
require_relative 'envutil'
class TestKeywordArguments < Test::Unit::TestCase
def f1(str: "foo", num: 424242)
@ -266,4 +267,11 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal(expect, rest_keyrest(*expect), bug7665)
assert_equal(expect, proc {|*args, **opt| next *args, opt}.call(*expect), bug7665)
end
def test_bare_kwrest
# valid syntax, but its semantics is undefined
assert_valid_syntax("def bug7662(**) end")
assert_valid_syntax("def bug7662(*, **) end")
assert_valid_syntax("def bug7662(a, **) end")
end
end