Skip to content

Commit

Permalink
[Bug #19025] Numbered parameter names are always local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed May 14, 2023
1 parent bdaa491 commit 91c0048
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parse.y
Expand Up @@ -9749,7 +9749,7 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
if (result == tCONSTANT && is_local_id(ident)) result = tIDENTIFIER;
if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
(result == tIDENTIFIER) && /* not EXPR_FNAME, not attrasgn */
lvar_defined(p, ident)) {
(lvar_defined(p, ident) || NUMPARAM_ID_P(ident))) {
SET_LEX_STATE(EXPR_END|EXPR_LABEL);
}
return result;
Expand Down
1 change: 1 addition & 0 deletions test/ruby/test_syntax.rb
Expand Up @@ -1672,6 +1672,7 @@ def test_numbered_parameter
}

assert_valid_syntax("proc {def foo(_);end;_1}")
assert_valid_syntax("p { [_1 **2] }")
end

def test_value_expr_in_condition
Expand Down

0 comments on commit 91c0048

Please sign in to comment.