added error message for using polymorphic structs
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Sep 2020 22:56:34 +0000 (17:56 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Sep 2020 22:56:34 +0000 (17:56 -0500)
onyx
progs/poly_struct.onyx
src/onyxsymres.c

diff --git a/onyx b/onyx
index 600acc296ddaf8c80a1097d4c4d8a6cb62e7f394..ec1d3be948189aa8a245629cca11b817cc7efebc 100755 (executable)
Binary files a/onyx and b/onyx differ
index 68c968d0f2841a25928f5a413f31620f6ceba23a..c3b784988698c41c6b020d28883571f150d48c53 100644 (file)
@@ -4,7 +4,6 @@ package main
 
 use package core
 
-
 main :: proc (args: [] cstring) {
     imap : I32Map(i32);
     i32map_init(^imap);
@@ -12,6 +11,11 @@ main :: proc (args: [] cstring) {
     i32map_put(^imap, 50, 1234);
     i32map_put(^imap, 1234, 5678);
 
+    print(i32map_has(^imap, 50));
+    print("\n");
+    print(i32map_has(^imap, 51));
+    print("\n");
+
     print(i32map_get(^imap, 50));
     print(i32map_get(^imap, 1234));
     print("\n");
index 1c650f5b44f6dc0a7671a608d201842828f58c7f..7257eb8530098498cfe73f6b17e3226bd68330b5 100644 (file)
@@ -569,6 +569,11 @@ void symres_function(AstFunction* func) {
                     st = (AstStructType *) ((AstPointerType *) param->local->type_node)->elem;
                 }
 
+                if (st->kind == Ast_Kind_Poly_Call_Type) {
+                    onyx_report_error(param->local->token->pos, "Currently, cannot 'use' a polymorphic struct type. This will be added in the future.");
+                    return;
+                }
+
                 bh_arr_each(AstStructMember *, mem, st->members) {
                     AstFieldAccess* fa = onyx_ast_node_new(semstate.node_allocator, sizeof(AstFieldAccess), Ast_Kind_Field_Access);
                     fa->token = (*mem)->token;