diff options
| author | Matt Valentine-House <matt@eightbitraptor.com> | 2023-11-30 12:05:48 +0000 |
|---|---|---|
| committer | Matt Valentine-House <matt@eightbitraptor.com> | 2023-11-30 21:31:57 +0000 |
| commit | 0c7c654b4da008fe18ebc822b1d76ee656eded01 (patch) | |
| tree | cf91404a972b3fa88a96630e6cf028a6a0436595 | |
| parent | 57782d3d47bcb52af0006ac75e75f3b3609b1d31 (diff) | |
[Prism] Fix local variable access for POST_EXECUTION_NODE
| -rw-r--r-- | prism_compile.c | 1 | ||||
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c index 2370b28982..dc1ecb1bf9 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -1398,6 +1398,7 @@ pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_ case PM_POST_EXECUTION_NODE: { pm_post_execution_node_t *cast = (pm_post_execution_node_t *) node; scope->body = (pm_node_t *) cast->statements; + scope->local_depth_offset += 2; break; } case PM_PROGRAM_NODE: { diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 1f0bce2037..fcc1f849d5 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -883,6 +883,8 @@ module Prism assert_prism_eval("END { 1 }") assert_prism_eval("END { @b }; @b = 1") assert_prism_eval("END { @b; 0 }; @b = 1") + assert_prism_eval("foo = 1; END { foo.nil? }") + assert_prism_eval("foo = 1; END { END { foo.nil? }}") end def test_ProgramNode |
