summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-13 21:15:13 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-13 21:16:00 +0900
commit0036648a420f945624898568bb82bc5f83195d12 (patch)
tree1ddad9a8be124fb58f74b614caddd20564a1b584 /parse.y
parente9b93d67baf8a6add548b7e5c702665100e4b3c9 (diff)
Capture to reserved name variables if already defined [Bug #17533]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4059
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y5
1 files changed, 3 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index cdd64f7071a..538153cc7a4 100644
--- a/parse.y
+++ b/parse.y
@@ -12811,12 +12811,13 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
NODE *node, *succ;
if (!len) return ST_CONTINUE;
- if (len < MAX_WORD_LENGTH && rb_reserved_word(s, (int)len))
- return ST_CONTINUE;
if (rb_enc_symname_type(s, len, enc, (1U<<ID_LOCAL)) != ID_LOCAL)
return ST_CONTINUE;
var = intern_cstr(s, len, enc);
+ if (len < MAX_WORD_LENGTH && rb_reserved_word(s, (int)len)) {
+ if (!lvar_defined(p, var)) return ST_CONTINUE;
+ }
node = node_assign(p, assignable(p, var, 0, arg->loc), NEW_LIT(ID2SYM(var), arg->loc), NO_LEX_CTXT, arg->loc);
succ = arg->succ_block;
if (!succ) succ = NEW_BEGIN(0, arg->loc);