This commit is contained in:
Krzosa Karol
2022-06-22 13:19:21 +02:00
parent 35daeade20
commit 33ba44989b

View File

@@ -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();
}