fix various semantic analyzer crashes
parent
8058b5e0a9
commit
d3de73739f
|
@ -2736,7 +2736,9 @@ static TypeTableEntry *analyze_bin_op_expr(CodeGen *g, ImportTableEntry *import,
|
|||
|
||||
TypeTableEntry *expected_rhs_type = analyze_lvalue(g, import, context, lhs_node,
|
||||
LValPurposeAssign, false);
|
||||
if (!is_op_allowed(expected_rhs_type, node->data.bin_op_expr.bin_op)) {
|
||||
if (expected_rhs_type->id == TypeTableEntryIdInvalid) {
|
||||
return g->builtin_types.entry_invalid;
|
||||
} else if (!is_op_allowed(expected_rhs_type, node->data.bin_op_expr.bin_op)) {
|
||||
if (expected_rhs_type->id != TypeTableEntryIdInvalid) {
|
||||
add_node_error(g, lhs_node,
|
||||
buf_sprintf("operator not allowed for type '%s'",
|
||||
|
@ -3001,7 +3003,9 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa
|
|||
}
|
||||
|
||||
TypeTableEntry *implicit_type = nullptr;
|
||||
if (variable_declaration->expr) {
|
||||
if (explicit_type && explicit_type->id == TypeTableEntryIdInvalid) {
|
||||
implicit_type = explicit_type;
|
||||
} else if (variable_declaration->expr) {
|
||||
implicit_type = analyze_expression(g, import, context, explicit_type, variable_declaration->expr);
|
||||
if (implicit_type->id == TypeTableEntryIdInvalid) {
|
||||
// ignore the poison value
|
||||
|
@ -3912,6 +3916,10 @@ static TypeTableEntry *analyze_fn_call_ptr(CodeGen *g, ImportTableEntry *import,
|
|||
{
|
||||
assert(node->type == NodeTypeFnCallExpr);
|
||||
|
||||
if (fn_type->id == TypeTableEntryIdInvalid) {
|
||||
return fn_type;
|
||||
}
|
||||
|
||||
// count parameters
|
||||
int src_param_count = fn_type->data.fn.fn_type_id.param_count;
|
||||
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
|
|||
static TypeTableEntry *analyze_expression(CodeGen *g, ImportTableEntry *import, BlockContext *context,
|
||||
TypeTableEntry *expected_type, AstNode *node)
|
||||
{
|
||||
assert(!expected_type || expected_type->id != TypeTableEntryIdInvalid);
|
||||
TypeTableEntry *return_type = nullptr;
|
||||
switch (node->type) {
|
||||
case NodeTypeBlock:
|
||||
|
|
|
@ -1718,14 +1718,10 @@ fn f() {
|
|||
i[i] = i[i];
|
||||
bad[bad] = bad[bad];
|
||||
}
|
||||
)SOURCE", 8, ".tmp_source.zig:4:5: error: use of undeclared identifier 'i'",
|
||||
)SOURCE", 4, ".tmp_source.zig:4:5: error: use of undeclared identifier 'i'",
|
||||
".tmp_source.zig:4:7: error: use of undeclared identifier 'i'",
|
||||
".tmp_source.zig:4:12: error: use of undeclared identifier 'i'",
|
||||
".tmp_source.zig:4:14: error: use of undeclared identifier 'i'",
|
||||
".tmp_source.zig:5:8: error: array access of non-array",
|
||||
".tmp_source.zig:5:9: error: expected type 'isize', got 'bool'",
|
||||
".tmp_source.zig:5:19: error: array access of non-array",
|
||||
".tmp_source.zig:5:20: error: expected type 'isize', got 'bool'");
|
||||
".tmp_source.zig:5:9: error: expected type 'isize', got 'bool'");
|
||||
|
||||
add_compile_fail_case("variadic functions only allowed in extern", R"SOURCE(
|
||||
fn f(...) {}
|
||||
|
|
Loading…
Reference in New Issue