Skip to content

Commit

Permalink
Actually a better way of dealing with polymorphic externals
Browse files Browse the repository at this point in the history
  • Loading branch information
msprotz committed Dec 11, 2023
1 parent f0b4a9a commit 6500a77
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/Checker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,17 @@ and infer env e =
check_subtype env t e.typ;
e.typ <- prefer_nominal t e.typ;
if Options.debug "checker" then KPrint.bprintf "[infer, now] %a\n" ptyp e.typ;
t

(* This is all because of external that retain their polymorphic
signatures. TODO: does this alleviate the need for those crappy checks in
subtype? *)
match Hashtbl.find_opt MonomorphizationState.state (flatten_tapp t) with
| exception Invalid_argument _ -> t
| Some (_, lid) ->
if Options.debug "checker" then
KPrint.bprintf "FOUND MONOMORPHIZATION %a\n" plid lid;
TQualified lid
| None -> t

and prefer_nominal t1 t2 =
match t1, t2 with
Expand All @@ -528,7 +538,6 @@ and best_buffer_type l t1 e2 =
| _ ->
TBuf (t1, false)


and infer' env e =
let infer_app t es =
let t_ret, t_args = flatten_arrow t in
Expand Down Expand Up @@ -914,6 +923,8 @@ and infer_branches env t_scrutinee branches =
) branches

and check_pat env t_context pat =
(* KPrint.bprintf "Checking pattern: %a\n" ppat pat; *)
(* KPrint.bprintf "t_context:%a\n" ptyp t_context; *)
match pat.node with
| PWild ->
pat.typ <- t_context
Expand Down

0 comments on commit 6500a77

Please sign in to comment.