diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-10 16:13:04 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-10 16:13:04 +0000 |
commit | 7449059cc64ead5a8e85b56db423faf0c8f21493 (patch) | |
tree | 46bdc0961c9d77a707f6706734562b517f3f7ffa | |
parent | 2994c621a1c016e8d534914416e0aebdb8159147 (diff) |
merge revision(s) 39504: [Backport #7942]
* parse.y (IS_LABEL_POSSIBLE): allow labels for keyword arguments just
after method definition without a parenthesis. [ruby-core:52820]
[Bug #7942]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@39708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ruby/test_keyword.rb | 16 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 24 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Mon Mar 11 01:12:50 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (IS_LABEL_POSSIBLE): allow labels for keyword arguments just + after method definition without a parenthesis. [ruby-core:52820] + [Bug #7942] + Mon Mar 11 01:09:23 2013 Zachary Scott <zachary@zacharyscott.net> * error.c: clarify reason for sleep in SignalException example @@ -6760,7 +6760,7 @@ parser_prepare(struct parser_params *parser) #define IS_END() IS_lex_state(EXPR_END_ANY) #define IS_BEG() IS_lex_state(EXPR_BEG_ANY) #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c)) -#define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG) && !cmd_state) || IS_ARG()) +#define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG | EXPR_ENDFN) && !cmd_state) || IS_ARG()) #define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1)) #define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT) diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 3685024991..66f9cc8dbb 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -274,4 +274,20 @@ class TestKeywordArguments < Test::Unit::TestCase assert_valid_syntax("def bug7662(*, **) end") assert_valid_syntax("def bug7662(a, **) end") end + + def test_without_paren + bug7942 = '[ruby-core:52820] [Bug #7942]' + assert_valid_syntax("def bug7942 a: 1; end") + assert_valid_syntax("def bug7942 a: 1, **; end") + + o = Object.new + eval("def o.bug7942 a: 1; a; end", nil, __FILE__, __LINE__) + assert_equal(1, o.bug7942(), bug7942) + assert_equal(42, o.bug7942(a: 42), bug7942) + + o = Object.new + eval("def o.bug7942 a: 1, **; a; end", nil, __FILE__, __LINE__) + assert_equal(1, o.bug7942(), bug7942) + assert_equal(42, o.bug7942(a: 42), bug7942) + end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-03-11" -#define RUBY_PATCHLEVEL 52 +#define RUBY_PATCHLEVEL 53 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 3 |