Browse Source

deal with FClosure in `unify_field_call` by transforming it to FInstance or FAnon (closes #3731)

Simon Krajewski 10 years ago
parent
commit
166c8f9b88
2 changed files with 17 additions and 0 deletions
  1. 14 0
      tests/unit/src/unit/issues/Issue3731.hx
  2. 3 0
      typer.ml

+ 14 - 0
tests/unit/src/unit/issues/Issue3731.hx

@@ -0,0 +1,14 @@
+package unit.issues;
+
+class Issue3731 extends Test {
+	function test() {
+		var arr = [];
+		make()(1);
+		eq(1, arr.length);
+		eq(1, arr[0]);
+	}
+
+	macro static public function make() {
+		return macro arr.push;
+	}
+}

+ 3 - 0
typer.ml

@@ -766,6 +766,9 @@ let unify_field_call ctx fa el args ret p inline =
 				List.map (fun (t,cf) -> map (monomorphs cf.cf_params t),cf) (Typeload.get_overloads c cf.cf_name)
 			in
 			(TFun(args,ret),cf) :: cfl,Some c,cf,(fun cf -> FInstance(c,tl,cf))
+		| FClosure(co,cf) ->
+			let c = match co with None -> None | Some (c,_) -> Some c in
+			expand_overloads (fun t -> t) cf,c,cf,(fun cf -> match co with None -> FAnon cf | Some (c,tl) -> FInstance(c,tl,cf))
 		| _ ->
 			error "Invalid field call" p
 	in