Browse Source

Merge pull request #4739 from jasonKercher/fix-4738

fix compiler crash on assigning a variable to an unresolved bit_set
gingerBill 6 months ago
parent
commit
36e86ba552
2 changed files with 4 additions and 2 deletions
  1. 1 1
      src/check_decl.cpp
  2. 3 1
      src/types.cpp

+ 1 - 1
src/check_decl.cpp

@@ -60,7 +60,7 @@ gb_internal Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *o
 				error(operand->expr, "Cannot assign a type '%s' to variable '%.*s'", t, LIT(e->token.string));
 				error(operand->expr, "Cannot assign a type '%s' to variable '%.*s'", t, LIT(e->token.string));
 			}
 			}
 			if (e->type == nullptr) {
 			if (e->type == nullptr) {
-				error_line("\tThe type of the variable '%.*s' cannot be inferred as a type does not have a default type\n", LIT(e->token.string));
+				error_line("\tThe type of the variable '%.*s' cannot be inferred as a type and does not have a default type\n", LIT(e->token.string));
 			}
 			}
 			e->type = operand->type;
 			e->type = operand->type;
 			return nullptr;
 			return nullptr;

+ 3 - 1
src/types.cpp

@@ -4773,7 +4773,9 @@ gb_internal gbString write_type_to_string(gbString str, Type *type, bool shortha
 
 
 	case Type_BitSet:
 	case Type_BitSet:
 		str = gb_string_appendc(str, "bit_set[");
 		str = gb_string_appendc(str, "bit_set[");
-		if (is_type_enum(type->BitSet.elem)) {
+		if (type->BitSet.elem == nullptr) {
+			str = gb_string_appendc(str, "<unresolved>");
+		} else if (is_type_enum(type->BitSet.elem)) {
 			str = write_type_to_string(str, type->BitSet.elem);
 			str = write_type_to_string(str, type->BitSet.elem);
 		} else {
 		} else {
 			str = gb_string_append_fmt(str, "%lld", type->BitSet.lower);
 			str = gb_string_append_fmt(str, "%lld", type->BitSet.lower);