зеркало из https://github.com/github/ruby.git
parse.y: kwarg to method with same name variable
* parse.y (parse_ident): allow keyword arguments just after a method where the same name local variable is defined. [ruby-core:73816] [Bug#12073] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5e59be3edd
Коммит
fbb51ff44c
|
@ -1,3 +1,9 @@
|
|||
Mon Feb 15 15:44:09 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (parse_ident): allow keyword arguments just after a
|
||||
method where the same name local variable is defined.
|
||||
[ruby-core:73816] [Bug#12073]
|
||||
|
||||
Mon Feb 15 14:43:28 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
* enc/unicode/case-folding.rb: Added debugging option
|
||||
|
|
2
parse.y
2
parse.y
|
@ -8073,7 +8073,7 @@ parse_ident(struct parser_params *parser, int c, int cmd_state)
|
|||
ident = tokenize_ident(parser, last_state);
|
||||
if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
|
||||
lvar_defined(ident)) {
|
||||
SET_LEX_STATE(EXPR_END);
|
||||
SET_LEX_STATE(EXPR_END|EXPR_LABEL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -360,6 +360,13 @@ WARN
|
|||
assert_valid_syntax("{label: <<~DOC\n""DOC\n""}", bug11849)
|
||||
end
|
||||
|
||||
def test_cmdarg_kwarg_lvar_clashing_method
|
||||
bug12073 = '[ruby-core:73816] [Bug#12073]'
|
||||
a = 1
|
||||
assert_valid_syntax("a b: 1")
|
||||
assert_valid_syntax("a = 1; a b: 1", bug12073)
|
||||
end
|
||||
|
||||
def test_duplicated_arg
|
||||
assert_syntax_error("def foo(a, a) end", /duplicated argument name/)
|
||||
assert_nothing_raised { def foo(_, _) end }
|
||||
|
|
Загрузка…
Ссылка в новой задаче