Browse Source

fix arguments positions for `.bind(a1, a2...)` expressions (closes #9226)

Aleksandr Kuzmenko 5 years ago
parent
commit
cdae99b3a7

+ 1 - 1
src/typing/calls.ml

@@ -782,7 +782,7 @@ let type_bind ctx (e : texpr) (args,ret) params p =
 			loop args params given_args (missing_args @ [v,o]) (ordered_args @ [vexpr v])
 		| (n,o,t) :: args , param :: params ->
 			let e = type_expr ctx param (WithType.with_argument t n) in
-			let e = AbstractCast.cast_or_unify ctx t e p in
+			let e = AbstractCast.cast_or_unify ctx t e (pos param) in
 			let v = alloc_var VGenerated (alloc_name n) t (pos param) in
 			loop args params (given_args @ [v,o,Some e]) missing_args (ordered_args @ [vexpr v])
 	in

+ 7 - 0
tests/misc/projects/Issue9226/Main.hx

@@ -0,0 +1,7 @@
+class Main {
+	function new(a:Int) {}
+
+	static function main() {
+		var f = Main.new.bind("not an int");
+	}
+}

+ 1 - 0
tests/misc/projects/Issue9226/compile-fail.hxml

@@ -0,0 +1 @@
+-main Main

+ 1 - 0
tests/misc/projects/Issue9226/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:5: characters 25-37 : String should be Int