瀏覽代碼

[typer] align some monomorphic weirdness

closes #9594
Simon Krajewski 5 年之前
父節點
當前提交
34a17aeeb4
共有 2 個文件被更改,包括 22 次插入0 次删除
  1. 7 0
      src/typing/typer.ml
  2. 15 0
      tests/unit/src/unit/issues/Issue9594.hx

+ 7 - 0
src/typing/typer.ml

@@ -451,6 +451,13 @@ let unify_int ctx e k =
 		match follow t with
 		| TAnon a ->
 			(try is_dynamic (PMap.find f a.a_fields).cf_type with Not_found -> false)
+		| TMono m ->
+			begin match Monomorph.classify_constraints m with
+			| CStructural(fields,_) ->
+				(try is_dynamic (PMap.find f fields).cf_type with Not_found -> false)
+			| _ ->
+				true
+			end
 		| TInst (c,tl) ->
 			(try is_dynamic (apply_params c.cl_params tl ((let _,t,_ = Type.class_field c tl f in t))) with Not_found -> false)
 		| _ ->

+ 15 - 0
tests/unit/src/unit/issues/Issue9594.hx

@@ -0,0 +1,15 @@
+package unit.issues;
+import unit.Test;
+
+class Issue9594 extends Test {
+	function test() {
+		var arr:Array<Array<Int>> = [];
+		arr.sort(sort);
+		utest.Assert.pass();
+	}
+
+	static function sort(a, b) {
+		if (a.length != b.length) return a.length - b.length;
+		return 0;
+	}
+}