From ecad2140dd8eb9e8c4b2d53a1112975c27d87fd0 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 17 Oct 2022 17:52:14 -0500 Subject: [PATCH] fixed tiny but significant double polymorph issue --- compiler/src/checker.c | 6 +++++- tests/bugs/double_polymorph_yield_error | 3 +++ tests/bugs/double_polymorph_yield_error.onyx | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/double_polymorph_yield_error create mode 100644 tests/bugs/double_polymorph_yield_error.onyx diff --git a/compiler/src/checker.c b/compiler/src/checker.c index 0854670c..2f2ad2f6 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -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 index 00000000..f605338a --- /dev/null +++ b/tests/bugs/double_polymorph_yield_error @@ -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 index 00000000..eec85551 --- /dev/null +++ b/tests/bugs/double_polymorph_yield_error.onyx @@ -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 -- 2.25.1