Browse Source

Correct tuple name checking for doc writing

gingerBill 3 years ago
parent
commit
5ff82fc113
3 changed files with 9 additions and 4 deletions
  1. 1 1
      src/docs_writer.cpp
  2. 1 1
      src/exact_value.cpp
  3. 7 2
      src/types.cpp

+ 1 - 1
src/docs_writer.cpp

@@ -483,7 +483,7 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
 	for_array(i, w->type_cache.entries) {
 		// NOTE(bill): THIS IS SLOW
 		Type *other = w->type_cache.entries[i].key;
-		if (are_types_identical(type, other)) {
+		if (are_types_identical(type, other, true)) {
 			OdinDocTypeIndex index = w->type_cache.entries[i].value;
 			map_set(&w->type_cache, type, index);
 			return index;

+ 1 - 1
src/exact_value.cpp

@@ -9,7 +9,7 @@ struct Ast;
 struct HashKey;
 struct Type;
 struct Entity;
-bool are_types_identical(Type *x, Type *y);
+bool are_types_identical(Type *x, Type *y, bool check_tuple_names=false);
 
 struct Complex128 {
 	f64 real, imag;

+ 7 - 2
src/types.cpp

@@ -694,7 +694,7 @@ gbString type_to_string       (Type *type);
 i64      type_size_of_internal(Type *t, TypePath *path);
 void     init_map_internal_types(Type *type);
 Type *   bit_set_to_int(Type *t);
-bool are_types_identical(Type *x, Type *y);
+bool are_types_identical(Type *x, Type *y, bool check_tuple_names/*=false*/);
 
 bool is_type_pointer(Type *t);
 bool is_type_proc(Type *t);
@@ -2338,7 +2338,7 @@ Type *strip_type_aliasing(Type *x) {
 	return x;
 }
 
-bool are_types_identical(Type *x, Type *y) {
+bool are_types_identical(Type *x, Type *y, bool check_tuple_names) {
 	if (x == y) {
 		return true;
 	}
@@ -2487,6 +2487,11 @@ bool are_types_identical(Type *x, Type *y) {
 					if (xe->kind != ye->kind || !are_types_identical(xe->type, ye->type)) {
 						return false;
 					}
+					if (check_tuple_names) {
+						if (xe->token.string != ye->token.string) {
+							return false;
+						}
+					}
 					if (xe->kind == Entity_Constant && !compare_exact_values(Token_CmpEq, xe->Constant.value, ye->Constant.value)) {
 						// NOTE(bill): This is needed for polymorphic procedures
 						return false;