Skip to content

Commit

Permalink
fix haxe.PosInfos regression (closes HaxeFoundation#3348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Sep 16, 2014
1 parent 7ea484b commit 1142dbc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
31 changes: 31 additions & 0 deletions tests/unit/issues/Issue3348.hx
Original file line number Diff line number Diff line change
@@ -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);
}
}
12 changes: 8 additions & 4 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1142dbc

Please sign in to comment.