From: Brendan Hansen Date: Mon, 14 Sep 2020 22:56:34 +0000 (-0500) Subject: added error message for using polymorphic structs X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=8c27e4302bc4bf2a6fd75a941f843e998297651e;p=onyx.git added error message for using polymorphic structs --- diff --git a/onyx b/onyx index 600acc29..ec1d3be9 100755 Binary files a/onyx and b/onyx differ diff --git a/progs/poly_struct.onyx b/progs/poly_struct.onyx index 68c968d0..c3b78498 100644 --- a/progs/poly_struct.onyx +++ b/progs/poly_struct.onyx @@ -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"); diff --git a/src/onyxsymres.c b/src/onyxsymres.c index 1c650f5b..7257eb85 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -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;