Skip to content

Commit 91c0048

Browse files
committed
[Bug #19025] Numbered parameter names are always local variables
1 parent bdaa491 commit 91c0048

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

parse.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9749,7 +9749,7 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
97499749
if (result == tCONSTANT && is_local_id(ident)) result = tIDENTIFIER;
97509750
if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
97519751
(result == tIDENTIFIER) && /* not EXPR_FNAME, not attrasgn */
9752-
lvar_defined(p, ident)) {
9752+
(lvar_defined(p, ident) || NUMPARAM_ID_P(ident))) {
97539753
SET_LEX_STATE(EXPR_END|EXPR_LABEL);
97549754
}
97559755
return result;

test/ruby/test_syntax.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,7 @@ def test_numbered_parameter
16721672
}
16731673

16741674
assert_valid_syntax("proc {def foo(_);end;_1}")
1675+
assert_valid_syntax("p { [_1 **2] }")
16751676
end
16761677

16771678
def test_value_expr_in_condition

0 commit comments

Comments
 (0)