]> Nishi Git Mirror - gwion.git/commitdiff
:bug: Fix perform in recursive funcs
authorJérémie Astor <fennecdjay@gmail.com>
Fri, 13 May 2022 15:48:13 +0000 (17:48 +0200)
committerJérémie Astor <fennecdjay@gmail.com>
Fri, 13 May 2022 15:48:13 +0000 (17:48 +0200)
src/vm/vm.c
tests/effects/check_ov.gw [new file with mode: 0644]
tests/effects/check_ov_inclass.gw [new file with mode: 0644]

index 2f8e41782c9f89cd076359758fcdbb22bb293d4b..e15b86aac3b642ba9b07efb5c456e913b685b297 100644 (file)
@@ -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 (file)
index 0000000..4c3faf3
--- /dev/null
@@ -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 (file)
index 0000000..7256d13
--- /dev/null
@@ -0,0 +1,14 @@
+#! [contains] gotcha
+fun void foo() { foo(); }
+
+class C {
+  fun void run() {
+    try {
+      foo();
+    } handle StackOverflow {
+      <<< "gotcha" >>>;
+    }
+  }
+  run();
+}
+new C;