Browse Source

Allow comparisons of `any` if `reflect.equal` if `including_indirect_array_recursion` is enabled

gingerBill 4 years ago
parent
commit
e3809f5c1b
1 changed files with 7 additions and 2 deletions
  1. 7 2
      core/reflect/reflect.odin

+ 7 - 2
core/reflect/reflect.odin

@@ -1320,10 +1320,15 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_
 	switch v in t.variant {
 	switch v in t.variant {
 	case Type_Info_Named:
 	case Type_Info_Named:
 		unreachable();
 		unreachable();
-	case Type_Info_Any:
-		return false;
 	case Type_Info_Tuple:
 	case Type_Info_Tuple:
 		unreachable();
 		unreachable();
+	case Type_Info_Any:
+		if !including_indirect_array_recursion {
+			return false;
+		}
+		va := (^any)(a.data);
+		vb := (^any)(b.data);
+		return equal(va, vb, including_indirect_array_recursion, recursion_level+1); 
 	case Type_Info_Map:
 	case Type_Info_Map:
 		return false;
 		return false;
 	case Type_Info_Relative_Slice:
 	case Type_Info_Relative_Slice: