From f43a919be494cf5b0f98f104da1024efda1abba5 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 17 Jan 2024 11:19:54 -0500 Subject: [PRISM] Fix fallthrough for PM_ENSURE_NODE This caused it to fall into PM_ELSE_NODE which caused ensure nodes to be compiled twice. Fixes ruby/prism#2176. --- test/ruby/test_compile_prism.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index c0f85af8b4..d547f82fe3 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -931,6 +931,21 @@ module Prism end a CODE + + # Test that ensure block only evaluated once + assert_prism_eval(<<~RUBY) + res = [] + begin + begin + raise + ensure + res << $!.to_s + end + rescue + res + end + RUBY + assert_prism_eval(<<-CODE) a = 1 begin -- cgit v1.2.3