Skip to content

Commit

Permalink
tanon identification / tunification: stricterer EqStricter
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Jan 22, 2024
1 parent e3d2826 commit 47ad4bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/core/tUnification.ml
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,11 @@ let rec type_eq uctx a b =
| _ , TLazy f -> type_eq uctx a (lazy_type f)
| TMono t , _ ->
(match t.tm_type with
| None -> if param = EqCoreType || not (link t a b) then error [cannot_unify a b]
| None -> if param = EqCoreType || param = EqStricter || not (link t a b) then error [cannot_unify a b]
| Some t -> type_eq uctx t b)
| _ , TMono t ->
(match t.tm_type with
| None -> if param = EqCoreType || not (link t b a) then error [cannot_unify a b]
| None -> if param = EqCoreType || param = EqStricter || not (link t b a) then error [cannot_unify a b]
| Some t -> type_eq uctx a t)
| TDynamic None, TDynamic None ->
()
Expand Down Expand Up @@ -630,7 +630,7 @@ let type_iseq uctx a b =

let type_iseq_strict a b =
try
type_eq {default_unification_context with equality_kind = EqDoNotFollowNull} a b;
type_eq {default_unification_context with equality_kind = EqStricter} a b;
true
with Unify_error _ ->
false
Expand Down Expand Up @@ -660,11 +660,11 @@ let rec unify (uctx : unification_context) a b =
| _ , TLazy f -> unify uctx a (lazy_type f)
| TMono t , _ ->
(match t.tm_type with
| None -> if not (link t a b) then error [cannot_unify a b]
| None -> if uctx.equality_kind = EqStricter || not (link t a b) then error [cannot_unify a b]
| Some t -> unify uctx t b)
| _ , TMono t ->
(match t.tm_type with
| None -> if not (link t b a) then error [cannot_unify a b]
| None -> if uctx.equality_kind = EqStricter || not (link t b a) then error [cannot_unify a b]
| Some t -> unify uctx a t)
| TType (t,tl) , _ ->
rec_stack unify_stack (a,b)
Expand Down Expand Up @@ -885,7 +885,7 @@ let rec unify (uctx : unification_context) a b =
error [cannot_unify a b]
end
| _ , TDynamic None ->
()
if uctx.equality_kind = EqStricter then error [cannot_unify a b]
| _ , TDynamic (Some t1) ->
begin match a with
| TAnon an ->
Expand Down
6 changes: 3 additions & 3 deletions src/typing/tanon_identification.ml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
open Globals
open Type

let replace_mono t =
let replace_mono tmono_as_tdynamic t =
let visited_anons = ref [] in
let rec loop t =
match t with
| TMono ({ tm_type = None }) ->
t_dynamic
if tmono_as_tdynamic then t_dynamic else t
| TAnon an ->
if not (List.memq an !visited_anons) then begin
visited_anons := an :: !visited_anons;
Expand Down Expand Up @@ -167,7 +167,7 @@ object(self)
end
| _ ->
let arity,fields = PMap.fold (fun cf (i,acc) ->
let t = replace_mono cf.cf_type in
let t = replace_mono (not strict) cf.cf_type in
(i + 1),(PMap.add cf.cf_name {cf with cf_type = t} acc)
) an.a_fields (0,PMap.empty) in
let an = { a_fields = fields; a_status = an.a_status; } in
Expand Down

0 comments on commit 47ad4bc

Please sign in to comment.