added passing macros as baked arguments
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 11 Sep 2021 23:17:38 +0000 (18:17 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 11 Sep 2021 23:17:38 +0000 (18:17 -0500)
bin/onyx
src/polymorph.c
src/symres.c

index fe7a9ff27dc1f51a074848f2edcd91d554ebeacb..c187c11aceef953d575d0f704f0c073e3b16dd15 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 8320f48b976734fbe43f353348856499101ac6cd..335eec9db8a4d6a5ab401ec5cd308945f84febd0 100644 (file)
@@ -497,14 +497,19 @@ static void solve_for_polymorphic_param_value(PolySolveResult* resolved, AstPoly
             param->type = type_build_from_ast(context.ast_alloc, param->type_expr);
         assert(param->type);
 
-        if (!unify_node_and_type(&value, param->type)) {
+        AstTyped* value_to_use = value;
+        if (value->kind == Ast_Kind_Macro) {
+            value_to_use = (AstTyped *) get_function_from_node((AstNode *) value);
+        }
+
+        if (!unify_node_and_type(&value_to_use, param->type)) {
             if (err_msg) *err_msg = bh_aprintf(global_scratch_allocator,
                     "The procedure '%s' expects a value of type '%s' for baked %d%s parameter, got '%s'.",
                     get_function_name(pp->base_func),
                     type_get_name(param->type),
                     param->idx + 1,
                     bh_num_suffix(param->idx + 1),
-                    node_get_type_name(value));
+                    node_get_type_name(value_to_use));
             return;
         }
 
index 4e1bcef734c50224e7bb447613dbdbda089f82e0..ad8544e98b24111324b12a232030737b9342faaa 100644 (file)
@@ -1185,6 +1185,8 @@ static SymresStatus symres_macro(AstMacro* macro) {
         SYMRES(polyproc, (AstPolyProc *) macro->body);
     }
 
+    macro->flags |= Ast_Flag_Comptime;
+
     return Symres_Success;
 }