Browse Source

[typer] load `(?arg:Type) -> Type` properly

closes #7179
Simon Krajewski 7 years ago
parent
commit
de21da52fc
2 changed files with 10 additions and 1 deletions
  1. 1 1
      src/typing/typeload.ml
  2. 9 0
      tests/unit/src/unit/issues/Issue7179.hx

+ 1 - 1
src/typing/typeload.ml

@@ -515,7 +515,7 @@ and load_complex_type' ctx allow_display (t,p) =
 			TFun ([],load_complex_type ctx allow_display r)
 		| _ ->
 			TFun (List.map (fun t ->
-				let t, opt = (match fst t with CTOptional t -> t, true | _ -> t,false) in
+				let t, opt = (match fst t with CTOptional t | CTParent((CTOptional t,_)) -> t, true | _ -> t,false) in
 				let n,t = (match fst t with CTNamed (n,t) -> (fst n), t | _ -> "", t) in
 				n,opt,load_complex_type ctx allow_display t
 			) args,load_complex_type ctx allow_display r)

+ 9 - 0
tests/unit/src/unit/issues/Issue7179.hx

@@ -0,0 +1,9 @@
+package unit.issues;
+
+class Issue7179 extends unit.Test {
+	function test() {
+		var f:(?f:Float) -> Void = function(?_) { }
+		f();
+		f(1.);
+	}
+}