From 33ba44989bfd9cf0e7493dfe5c3a7baf38bf2497 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Wed, 22 Jun 2022 13:19:21 +0200 Subject: [PATCH] Cleanup --- typechecking.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/typechecking.cpp b/typechecking.cpp index 67c1ae8..1321e18 100644 --- a/typechecking.cpp +++ b/typechecking.cpp @@ -469,6 +469,9 @@ try_propagating_resolved_type_to_untyped_literals(Ast *ast, Ast_Type *type, Ast_ if(!ast) return; if(is_untyped(type)) return; + // @note: + // Normal untyped should only be 1 deep cause we make sure to colapse all constants + // and only constants can be untyped if(!is_bool(type)){ if(ast->kind != AST_VALUE) return; @@ -477,6 +480,7 @@ try_propagating_resolved_type_to_untyped_literals(Ast *ast, Ast_Type *type, Ast_ return; } + // Boolean special case switch(ast->kind){ CASE(IDENT, Atom){ type = additional_not_bool_type ? additional_not_bool_type : type; @@ -493,10 +497,6 @@ try_propagating_resolved_type_to_untyped_literals(Ast *ast, Ast_Type *type, Ast_ CASE(BINARY, Binary){ Value value = {}; value.type = node->resolved_type; // @cleanup node->resolved_type = convert_untyped_to_typed(ast->pos, value, type).type; - - // memes: int = 10 - // thing: Bool = int == (20 + 10) - try_propagating_resolved_type_to_untyped_literals(node->left, type, node->right->resolved_type); try_propagating_resolved_type_to_untyped_literals(node->right, type, node->left->resolved_type); BREAK(); @@ -514,6 +514,8 @@ try_propagating_resolved_type_to_untyped_literals(Ast *ast, Ast_Type *type, Ast_ try_propagating_resolved_type_to_untyped_literals(node->expr, type); BREAK(); } + + default:{} } } @@ -989,15 +991,6 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){ } CASE(VALUE, Atom){ - // @todo: More propagation of const char to sub values - if(compound_context){ - if(is_string(node->value.type) && is_string(compound_context)){ - node->value.type = compound_context; - } - if(is_any(compound_context)){ - try_converting_untyped_to_typed(&node->value); - } - } return operand_const_rvalue(node->value); BREAK(); }