Browse Source

Fix error block handling

gingerBill 1 year ago
parent
commit
5159f30c9c
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/check_type.cpp

+ 4 - 2
src/check_type.cpp

@@ -3349,7 +3349,7 @@ gb_internal Type *check_type_expr(CheckerContext *ctx, Ast *e, Type *named_type)
 		gbString err_str = expr_to_string(e);
 		gbString err_str = expr_to_string(e);
 		defer (gb_string_free(err_str));
 		defer (gb_string_free(err_str));
 
 
-		ERROR_BLOCK();
+		begin_error_block();
 		error(e, "'%s' is not a type", err_str);
 		error(e, "'%s' is not a type", err_str);
 
 
 		type = t_invalid;
 		type = t_invalid;
@@ -3368,14 +3368,16 @@ gb_internal Type *check_type_expr(CheckerContext *ctx, Ast *e, Type *named_type)
 			defer (gb_string_free(type_str));
 			defer (gb_string_free(type_str));
 
 
 			error_line("\tSuggestion: Did you mean '[%s]%s'?", index_str ? index_str : "", type_str);
 			error_line("\tSuggestion: Did you mean '[%s]%s'?", index_str ? index_str : "", type_str);
+			end_error_block();
 
 
 			// NOTE(bill): Minimize error propagation of bad array syntax by treating this like a type
 			// NOTE(bill): Minimize error propagation of bad array syntax by treating this like a type
 			if (node->IndexExpr.expr != nullptr) {
 			if (node->IndexExpr.expr != nullptr) {
 				Ast *pseudo_array_expr = ast_array_type(e->file(), ast_token(node->IndexExpr.expr), node->IndexExpr.index, node->IndexExpr.expr);
 				Ast *pseudo_array_expr = ast_array_type(e->file(), ast_token(node->IndexExpr.expr), node->IndexExpr.index, node->IndexExpr.expr);
 				check_array_type_internal(ctx, pseudo_array_expr, &type, nullptr);
 				check_array_type_internal(ctx, pseudo_array_expr, &type, nullptr);
 			}
 			}
+		} else {
+			end_error_block();
 		}
 		}
-
 	}
 	}
 
 
 	if (type == nullptr) {
 	if (type == nullptr) {