diff options
author | Seiei Miyagi <[email protected]> | 2019-04-23 00:21:50 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-04-23 12:16:15 +0900 |
commit | 6ca9e7cc0785c33f6d382176dbd79d6c91db72fe (patch) | |
tree | 6837a6a956435dcba754e6bdff60fd0a4c506ba5 | |
parent | ae07b66aaa092c59ac9d544c9b582712290dc357 (diff) |
Disallow numbered parameter as the default value of optional argument
[Fix GH-2139] [Bug #15783]
-rw-r--r-- | parse.y | 1 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 1 |
2 files changed, 2 insertions, 0 deletions
@@ -4735,6 +4735,7 @@ f_norm_arg : f_bad_arg | tIDENTIFIER { formal_argument(p, get_id($1)); + p->max_numparam = -1; $$ = $1; } ; diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 488962b003..257fe07b3c 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1302,6 +1302,7 @@ eom assert_syntax_error('->(x){@1}', /ordinary parameter is defined/) assert_syntax_error('->x{@1}', /ordinary parameter is defined/) assert_syntax_error('->x:@2{}', /ordinary parameter is defined/) + assert_syntax_error('->x=@1{}', /ordinary parameter is defined/) assert_syntax_error('proc {@1 = nil}', /Can't assign to numbered parameter @1/) assert_syntax_error('proc {@01}', /leading zero/) assert_syntax_error('proc {@1_}', /unexpected/) |