summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-04-21 16:04:36 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-04-21 16:04:36 +0900
commit3ddf6ad4d2f6dae4caa00b8c407768c7062099a0 (patch)
tree077a624b7692f090bb9e35fb26738ca426870b54 /test/ruby
parentee48c9cda6e918f8da4b23d3ff4fabf7357f4a95 (diff)
Private local variables should shadow outer variables [Bug #18629]
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_parse.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index d697a29c1c..2841e20f6d 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -930,6 +930,10 @@ x = __ENCODING__
assert_no_warning(/shadowing outer local variable/) {eval("a=1; tap {|a|}")}
end
+ def test_shadowing_private_local_variable
+ assert_equal 1, eval("_ = 1; [[2]].each{ |(_)| }; _")
+ end
+
def test_unused_variable
o = Object.new
assert_warning(/assigned but unused variable/) {o.instance_eval("def foo; a=1; nil; end")}