Browse Source

fix haxe.PosInfos regression (closes #3348)

Simon Krajewski 11 years ago
parent
commit
1142dbcf5e
2 changed files with 39 additions and 4 deletions
  1. 31 0
      tests/unit/issues/Issue3348.hx
  2. 8 4
      typer.ml

+ 31 - 0
tests/unit/issues/Issue3348.hx

@@ -0,0 +1,31 @@
+package unit.issues;
+
+class Issue3348 extends Test {
+
+	function test() {
+		eq("unit.issues.Issue3348,Issue3348.hx,6,test", getPos1());
+		eq("unit.issues.Issue3348,Issue3348.hx,7,test", getPos2());
+		eq("unit.issues.Issue3348,Issue3348.hx,8,test", getPos3("ok"));
+		eq("unit.issues.Issue3348,Issue3348.hx,9,test", getPos4(1));
+	}
+
+	static function getPosString(p:haxe.PosInfos) {
+		return [p.className, p.fileName, Std.string(p.lineNumber), p.methodName].join(",");
+	}
+
+	static function getPos1(?p:haxe.PosInfos) {
+		return getPosString(p);
+	}
+
+	static function getPos2(?s:String, ?p:haxe.PosInfos) {
+		return getPosString(p);
+	}
+
+	static function getPos3(s:String, ?p:haxe.PosInfos) {
+		return getPosString(p);
+	}
+
+	static function getPos4(?s:String, ?i:Int, ?p:haxe.PosInfos) {
+		return getPosString(p);
+	}
+}

+ 8 - 4
typer.ml

@@ -676,11 +676,13 @@ let rec unify_call_args' ctx el args r p inline force_inline =
 		let err = Stack (Unify ul,Custom ("For " ^ (if opt then "optional " else "") ^ "function argument '" ^ name ^ "'")) in
 		call_error (Could_not_unify err) p
 	in
+	let mk_pos_infos t =
+		let infos = mk_infos ctx p [] in
+		type_expr ctx infos (WithType t)
+	in
 	let rec default_value name t =
 		if is_pos_infos t then
-			let infos = mk_infos ctx p [] in
-			let e = type_expr ctx infos (WithType t) in
-			e
+			mk_pos_infos t
 		else
 			null (ctx.t.tnull t) p
 	in
@@ -711,7 +713,9 @@ let rec unify_call_args' ctx el args r p inline force_inline =
 			call_error Not_enough_arguments p
 		| [],(name,true,t) :: args ->
 			begin match loop [] args with
-				| [] when not (inline && (ctx.g.doinline || force_inline)) && not ctx.com.config.pf_pad_nulls -> []
+				| [] when not (inline && (ctx.g.doinline || force_inline)) && not ctx.com.config.pf_pad_nulls ->
+					if is_pos_infos t then [mk_pos_infos t,true]
+					else []
 				| args ->
 					let e_def = default_value name t in
 					(e_def,true) :: args