diff options
| author | Jemma Issroff <jemmaissroff@gmail.com> | 2023-11-20 16:27:20 -0500 |
|---|---|---|
| committer | Jemma Issroff <jemmaissroff@gmail.com> | 2023-11-20 13:48:46 -0800 |
| commit | 103bbd21f884c279fc8368dac5cc4f62d68231af (patch) | |
| tree | afa9e1f3c15e6779e96b1abf543373f27520e973 | |
| parent | b913626bea138908102cb6b2c9a6bf9438428c76 (diff) | |
[PRISM] Updated LocalVariableTargetNodes too
| -rw-r--r-- | prism_compile.c | 3 | ||||
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/prism_compile.c b/prism_compile.c index ed171c4584..b202753261 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -2883,8 +2883,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, pm_local_variable_target_node_t *local_write_node = (pm_local_variable_target_node_t *) node; pm_constant_id_t constant_id = local_write_node->name; - for (size_t index = 0; index < local_write_node->depth; index++) scope_node = scope_node->previous; - int index = pm_lookup_local_index(iseq, scope_node, constant_id); + int index = pm_lookup_local_index_any_scope(iseq, scope_node, constant_id); ADD_SETLOCAL(ret, &dummy_line_node, index, local_write_node->depth); return; diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index b2454165c1..3b10244c96 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -350,6 +350,14 @@ module Prism def test_LocalVariableTargetNode assert_prism_eval("pit, pit1 = 1") + assert_prism_eval(<<-CODE) + a = 1 + [1].each do + c = 2 + a, b = 2 + end + a + CODE end def test_MultiTargetNode |
