ruby-changes:59713
From: Nobuyoshi <ko1@a...>
Date: Thu, 16 Jan 2020 18:56:01 +0900 (JST)
Subject: [ruby-changes:59713] c171ab23e3 (master): Separate numbered parameter scope in eval
https://git.ruby-lang.org/ruby.git/commit/?id=c171ab23e3 From c171ab23e376b6c7f1094a77f137d916b0a403e6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 16 Jan 2020 18:38:48 +0900 Subject: Separate numbered parameter scope in eval [Feature #16432] diff --git a/parse.y b/parse.y index 21b384d..1facda5 100644 --- a/parse.y +++ b/parse.y @@ -12041,7 +12041,7 @@ dvar_defined_ref(struct parser_params *p, ID id, ID **vidrefp) https://github.com/ruby/ruby/blob/trunk/parse.y#L12041 if (used) used = used->prev; } - if (vars == DVARS_INHERIT) { + if (vars == DVARS_INHERIT && !NUMPARAM_ID_P(id)) { return rb_dvar_defined(id, p->parent_iseq); } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index b93062c..5591b7c 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1450,7 +1450,13 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1450 assert_valid_syntax("->{_1;#{c};->{_1};end}\n") end - 1.times {_1} + 1.times { + [ + _1, + assert_equal([:a], eval("[:a].map{_1}")), + assert_raise(NameError) {eval("_1")}, + ] + } end def test_value_expr_in_condition -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/