fixed tiny but significant double polymorph issue
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 17 Oct 2022 22:52:14 +0000 (17:52 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 17 Oct 2022 22:52:14 +0000 (17:52 -0500)
compiler/src/checker.c
tests/bugs/double_polymorph_yield_error [new file with mode: 0644]
tests/bugs/double_polymorph_yield_error.onyx [new file with mode: 0644]

index 0854670cc77050d7e7b6ca8b355f1a79874de13b..2f2ad2f6bc78f28512992eb888851e29786329ff 100644 (file)
@@ -3150,7 +3150,11 @@ CheckStatus check_polyquery(AstPolyQuery *query) {
                 goto poly_var_solved;
 
             case TYPE_MATCH_SPECIAL:
-                return Check_Yield_Macro;
+                if (solved_something || query->successful_symres) {
+                    return Check_Return_To_Symres;    
+                } else {
+                    return Check_Yield_Macro;
+                }
 
             case TYPE_MATCH_YIELD:
             case TYPE_MATCH_FAILED: {
diff --git a/tests/bugs/double_polymorph_yield_error b/tests/bugs/double_polymorph_yield_error
new file mode 100644 (file)
index 0000000..f605338
--- /dev/null
@@ -0,0 +1,3 @@
+0x110A0
+false
+bool
diff --git a/tests/bugs/double_polymorph_yield_error.onyx b/tests/bugs/double_polymorph_yield_error.onyx
new file mode 100644 (file)
index 0000000..eec8555
--- /dev/null
@@ -0,0 +1,15 @@
+#load "core/std"
+
+use core
+
+q :: (v: ^$C, g: (^C) -> $T) {
+    println(v);
+    println(g(v));
+    println(T);
+}
+
+main :: () {
+    v := 5;
+
+    q(^v, _ => false);
+}
\ No newline at end of file