From d4cd99fd262216cc56b7e3c625c93d425ca95935 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 13 May 2022 17:48:13 +0200 Subject: [PATCH] :bug: Fix perform in recursive funcs --- src/vm/vm.c | 2 +- tests/effects/check_ov.gw | 11 +++++++++++ tests/effects/check_ov_inclass.gw | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/effects/check_ov.gw create mode 100644 tests/effects/check_ov_inclass.gw 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; -- 2.43.0