summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2023-11-20 15:40:35 -0500
committerJemma Issroff <jemmaissroff@gmail.com>2023-11-20 13:48:46 -0800
commitb913626bea138908102cb6b2c9a6bf9438428c76 (patch)
treea68a2db930c7665212223ea6b8f4acad4e6c79cf /test/ruby
parentf9628fb4be1c5eb5a652a6c3d3d97530bdcc76a5 (diff)
[PRISM] Fix LocalVariableWriteNodes within blocks
Prior to this commit, we weren't recursing up scopes to look for the local definition. With this commit, we do so, fixing local writes within blocks
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_compile_prism.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index 0ed9d3e2e0..b2454165c1 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -268,6 +268,28 @@ module Prism
def test_LocalVariableWriteNode
assert_prism_eval("pit = 1")
+ assert_prism_eval(<<-CODE)
+ a = 0
+ [].each do
+ a = 1
+ end
+ a
+ CODE
+
+ assert_prism_eval(<<-CODE)
+ a = 1
+ d = 1
+ [1].each do
+ b = 2
+ a = 2
+ [2].each do
+ c = 3
+ d = 4
+ a = 2
+ end
+ end
+ [a, d]
+ CODE
end
def test_MatchWriteNode