Skip to content

Commit

Permalink
use unify_or_cast for Context.unify to retain old behavior (see Hax…
Browse files Browse the repository at this point in the history
…eFoundation#3346) (test follows)
  • Loading branch information
Simn committed Sep 16, 2014
1 parent ee780ee commit fe2244a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions interp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ type extern_api = {
delayed_macro : int -> (unit -> (unit -> value));
use_cache : unit -> bool;
format_string : string -> Ast.pos -> Ast.expr;
cast_or_unify : Type.t -> texpr -> Ast.pos -> Type.texpr;
}

type callstack = {
Expand Down Expand Up @@ -2344,8 +2345,9 @@ let macro_lib =
with Exit -> VNull
);
"unify", Fun2 (fun t1 t2 ->
try Type.unify (decode_type t1) (decode_type t2); VBool true
with Unify_error _ -> VBool false
let e1 = mk (TConst TNull) (decode_type t1) Ast.null_pos in
try ignore(((get_ctx()).curapi.cast_or_unify) (decode_type t2) e1 Ast.null_pos); VBool true
with Typecore.Error (Typecore.Unify _,_) -> VBool false
);
"typeof", Fun1 (fun v ->
encode_type ((get_ctx()).curapi.type_expr (decode_expr v)).etype
Expand Down
3 changes: 3 additions & 0 deletions typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4387,6 +4387,9 @@ let make_macro_api ctx p =
Interp.format_string = (fun s p ->
format_string ctx s p
);
Interp.cast_or_unify = (fun t e p ->
Codegen.AbstractCast.cast_or_unify_raise ctx t e p
);
}

let rec init_macro_interp ctx mctx mint =
Expand Down

0 comments on commit fe2244a

Please sign in to comment.