Selaa lähdekoodia

do not unify_min enum type parameters to Dynamic (closes #6757, effectively reverts 41c80ba1d325fd6598f09c97d108f4298dc653b9)

Dan Korostelev 7 vuotta sitten
vanhempi
commit
3db8b7e3a1

+ 0 - 3
src/typing/typer.ml

@@ -294,9 +294,6 @@ let rec unify_min_raise ctx (el:texpr list) : t =
 					let t = apply_params cl.cl_params params (TInst (csup,pl)) in
 					loop t);
 				tl := t :: !tl;
-			| TEnum(en,(_ :: _ as tl2)) ->
-				tl := (TEnum(en,List.map (fun _ -> t_dynamic) tl2)) :: !tl;
-				tl := t :: !tl;
 			| TType (td,pl) ->
 				loop (apply_params td.t_params pl td.t_type);
 				(* prioritize the most generic definition *)

+ 12 - 0
tests/misc/projects/Issue6757/Test.hx

@@ -0,0 +1,12 @@
+import haxe.ds.Option;
+
+class Test {
+  static function which(v:Int) return
+    v > 1 ? Some("abc") : Some(true);
+
+  static function main() {
+    var r = which(1);
+    $type(r); // Option<Dynamic>
+    trace(r);
+  }
+}

+ 2 - 0
tests/misc/projects/Issue6757/compile-fail.hxml

@@ -0,0 +1,2 @@
+-main Test
+--interp

+ 4 - 0
tests/misc/projects/Issue6757/compile-fail.hxml.stderr

@@ -0,0 +1,4 @@
+Test.hx:5: characters 27-37 : haxe.ds.Option<Bool> should be haxe.ds.Option<String>
+Test.hx:5: characters 27-37 : Type parameters are invariant
+Test.hx:5: characters 27-37 : Bool should be String
+Test.hx:9: characters 11-12 : Warning : haxe.ds.Option<String>