From: Brendan Hansen Date: Sat, 16 Jan 2021 19:29:24 +0000 (-0600) Subject: add little bit more safety when using types in expressions X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=4c758cc0d26c00da670432dd4a129fe48ed6a317;p=onyx.git add little bit more safety when using types in expressions --- diff --git a/onyx.exe b/onyx.exe index 1f1fd9c0..56828a13 100644 Binary files a/onyx.exe and b/onyx.exe differ diff --git a/src/onyxastnodes.c b/src/onyxastnodes.c index 8d53e8ff..51a12a11 100644 --- a/src/onyxastnodes.c +++ b/src/onyxastnodes.c @@ -472,6 +472,10 @@ Type* resolve_expression_type(AstTyped* node) { node->type = resolve_expression_type(((AstArgument *) node)->value); } + if (node_is_type((AstNode *) node)) { + return NULL; + } + if (node->type == NULL) node->type = type_build_from_ast(semstate.allocator, node->type_node); diff --git a/src/onyxsymres.c b/src/onyxsymres.c index e44c4b97..c61fc523 100644 --- a/src/onyxsymres.c +++ b/src/onyxsymres.c @@ -353,6 +353,11 @@ static void symres_array_literal(AstArrayLiteral* al) { } static void symres_expression(AstTyped** expr) { + if (node_is_type((AstNode *) *expr)) { + *((AstType **) expr) = symres_type((AstType *) *expr); + return; + } + switch ((*expr)->kind) { case Ast_Kind_Symbol: *expr = (AstTyped *) symbol_resolve(semstate.curr_scope, ((AstNode *) *expr)->token);