Skip to content

Commit 465eb74

Browse files
committed
merge revision(s) 91c0048: [Backport #19025]
[Bug #19025] Numbered parameter names are always local variables --- parse.y | 2 +- test/ruby/test_syntax.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
1 parent e65e0b9 commit 465eb74

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

parse.y

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9775,9 +9775,9 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
97759775
ident = tokenize_ident(p, last_state);
97769776
if (result == tCONSTANT && is_local_id(ident)) result = tIDENTIFIER;
97779777
if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) &&
9778-
(result == tIDENTIFIER) && /* not EXPR_FNAME, not attrasgn */
9779-
lvar_defined(p, ident)) {
9780-
SET_LEX_STATE(EXPR_END|EXPR_LABEL);
9778+
(result == tIDENTIFIER) && /* not EXPR_FNAME, not attrasgn */
9779+
(lvar_defined(p, ident) || NUMPARAM_ID_P(ident))) {
9780+
SET_LEX_STATE(EXPR_END|EXPR_LABEL);
97819781
}
97829782
return result;
97839783
}

test/ruby/test_syntax.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,8 @@ def test_numbered_parameter
16701670
assert_raise(NameError) {eval("_1")},
16711671
]
16721672
}
1673+
1674+
assert_valid_syntax("p { [_1 **2] }")
16731675
end
16741676

16751677
def test_value_expr_in_condition

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 2
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 95
14+
#define RUBY_PATCHLEVEL 96
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)