Skip to content

Commit

Permalink
follow with_type when constructing map literals (closes HaxeFoundatio…
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed May 8, 2014
1 parent 7e1efb6 commit 7a50268
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 13 additions & 0 deletions tests/unit/issues/Issue2960.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package unit.issues;

class Issue2960 extends Test {
static var map:Map<String, haxe.Constraints.Function>;

static function call(m) {
map = m;
}

function test() {
call(["a" => function() {}]);
}
}
13 changes: 9 additions & 4 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2635,10 +2635,15 @@ and type_expr ctx (e,p) (with_type:with_type) =
]) v.v_type p
| EArrayDecl ((EBinop(OpArrow,_,_),_) as e1 :: el) ->
let keys = Hashtbl.create 0 in
let tkey,tval,resume = match with_type with
| WithType (TAbstract({a_path=[],"Map"},[tk;tv])) -> tk,tv,false
| WithTypeResume (TAbstract({a_path=[],"Map"},[tk;tv])) -> tk,tv,true
| _ -> mk_mono(),mk_mono(),false
let (tkey,tval),resume =
let get_map_params t = match follow t with
| TAbstract({a_path=[],"Map"},[tk;tv]) -> tk,tv
| _ -> mk_mono(),mk_mono()
in
match with_type with
| WithType t -> get_map_params t,false
| WithTypeResume t -> get_map_params t,true
| _ -> (mk_mono(),mk_mono()),false
in
let unify_with_resume ctx a b p =
if resume then try unify_raise ctx a b p with Error (Unify l,p) -> raise (WithTypeError(l,p))
Expand Down

0 comments on commit 7a50268

Please sign in to comment.