From: Jérémie Astor Date: Fri, 13 May 2022 15:48:13 +0000 (+0200) Subject: :bug: Fix perform in recursive funcs X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d4cd99fd262216cc56b7e3c625c93d425ca95935;p=gwion.git :bug: Fix perform in recursive funcs --- diff --git a/src/vm/vm.c b/src/vm/vm.c index 2f8e4178..e15b86aa 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -103,7 +103,7 @@ ANN static bool unwind(const VM_Shred shred, const Symbol effect, const m_uint s if (shred->mem == (m_bit *)shred + sizeof(struct VM_Shred_) + SIZEOF_REG) return false; shred_unwind(shred); - return unwind(shred, effect, size - 1); + return unwind(shred, effect, size - (code != shred->code)); } ANN static void trace(VM_Shred shred, const m_uint size) { diff --git a/tests/effects/check_ov.gw b/tests/effects/check_ov.gw new file mode 100644 index 00000000..4c3faf31 --- /dev/null +++ b/tests/effects/check_ov.gw @@ -0,0 +1,11 @@ +#! [contains] gotcha +fun void foo() { foo(); } + +fun void run() { + try { + foo(); + } handle StackOverflow { + <<< "gotcha" >>>; + } +} +run(); diff --git a/tests/effects/check_ov_inclass.gw b/tests/effects/check_ov_inclass.gw new file mode 100644 index 00000000..7256d137 --- /dev/null +++ b/tests/effects/check_ov_inclass.gw @@ -0,0 +1,14 @@ +#! [contains] gotcha +fun void foo() { foo(); } + +class C { + fun void run() { + try { + foo(); + } handle StackOverflow { + <<< "gotcha" >>>; + } + } + run(); +} +new C;