| ... | @@ -2736,7 +2736,9 @@ static TypeTableEntry *analyze_bin_op_expr(CodeGen *g, ImportTableEntry *import, | ... | @@ -2736,7 +2736,9 @@ static TypeTableEntry *analyze_bin_op_expr(CodeGen *g, ImportTableEntry *import, |
| 2736 | | 2736 | |
| 2737 | TypeTableEntry *expected_rhs_type = analyze_lvalue(g, import, context, lhs_node, | 2737 | TypeTableEntry *expected_rhs_type = analyze_lvalue(g, import, context, lhs_node, |
| 2738 | LValPurposeAssign, false); | 2738 | LValPurposeAssign, false); |
| 2739 | if (!is_op_allowed(expected_rhs_type, node->data.bin_op_expr.bin_op)) { | 2739 | if (expected_rhs_type->id == TypeTableEntryIdInvalid) { |
| | 2740 | return g->builtin_types.entry_invalid; |
| | 2741 | } else if (!is_op_allowed(expected_rhs_type, node->data.bin_op_expr.bin_op)) { |
| 2740 | if (expected_rhs_type->id != TypeTableEntryIdInvalid) { | 2742 | if (expected_rhs_type->id != TypeTableEntryIdInvalid) { |
| 2741 | add_node_error(g, lhs_node, | 2743 | add_node_error(g, lhs_node, |
| 2742 | buf_sprintf("operator not allowed for type '%s'", | 2744 | buf_sprintf("operator not allowed for type '%s'", |
| ... | @@ -3001,7 +3003,9 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa | ... | @@ -3001,7 +3003,9 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa |
| 3001 | } | 3003 | } |
| 3002 | | 3004 | |
| 3003 | TypeTableEntry *implicit_type = nullptr; | 3005 | TypeTableEntry *implicit_type = nullptr; |
| 3004 | if (variable_declaration->expr) { | 3006 | if (explicit_type && explicit_type->id == TypeTableEntryIdInvalid) { |
| | 3007 | implicit_type = explicit_type; |
| | 3008 | } else if (variable_declaration->expr) { |
| 3005 | implicit_type = analyze_expression(g, import, context, explicit_type, variable_declaration->expr); | 3009 | implicit_type = analyze_expression(g, import, context, explicit_type, variable_declaration->expr); |
| 3006 | if (implicit_type->id == TypeTableEntryIdInvalid) { | 3010 | if (implicit_type->id == TypeTableEntryIdInvalid) { |
| 3007 | // ignore the poison value | 3011 | // ignore the poison value |
| ... | @@ -3912,6 +3916,10 @@ static TypeTableEntry *analyze_fn_call_ptr(CodeGen *g, ImportTableEntry *import, | ... | @@ -3912,6 +3916,10 @@ static TypeTableEntry *analyze_fn_call_ptr(CodeGen *g, ImportTableEntry *import, |
| 3912 | { | 3916 | { |
| 3913 | assert(node->type == NodeTypeFnCallExpr); | 3917 | assert(node->type == NodeTypeFnCallExpr); |
| 3914 | | 3918 | |
| | 3919 | if (fn_type->id == TypeTableEntryIdInvalid) { |
| | 3920 | return fn_type; |
| | 3921 | } |
| | 3922 | |
| 3915 | // count parameters | 3923 | // count parameters |
| 3916 | int src_param_count = fn_type->data.fn.fn_type_id.param_count; | 3924 | int src_param_count = fn_type->data.fn.fn_type_id.param_count; |
| 3917 | int actual_param_count = node->data.fn_call_expr.params.length; | 3925 | int actual_param_count = node->data.fn_call_expr.params.length; |
| ... | @@ -4478,6 +4486,7 @@ static TypeTableEntry *analyze_asm_expr(CodeGen *g, ImportTableEntry *import, Bl | ... | @@ -4478,6 +4486,7 @@ static TypeTableEntry *analyze_asm_expr(CodeGen *g, ImportTableEntry *import, Bl |
| 4478 | static TypeTableEntry *analyze_expression(CodeGen *g, ImportTableEntry *import, BlockContext *context, | 4486 | static TypeTableEntry *analyze_expression(CodeGen *g, ImportTableEntry *import, BlockContext *context, |
| 4479 | TypeTableEntry *expected_type, AstNode *node) | 4487 | TypeTableEntry *expected_type, AstNode *node) |
| 4480 | { | 4488 | { |
| | 4489 | assert(!expected_type || expected_type->id != TypeTableEntryIdInvalid); |
| 4481 | TypeTableEntry *return_type = nullptr; | 4490 | TypeTableEntry *return_type = nullptr; |
| 4482 | switch (node->type) { | 4491 | switch (node->type) { |
| 4483 | case NodeTypeBlock: | 4492 | case NodeTypeBlock: |