Skip to content

Commit

Permalink
Revert "remove MEmptyStructure"
Browse files Browse the repository at this point in the history
This reverts commit 47c1f5b.
  • Loading branch information
Simn committed Dec 4, 2024
1 parent 47c1f5b commit 4897bcb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/core/tPrinting.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ and s_constraint = function
| MMono(m,_) -> Printf.sprintf "MMono %s" (s_type_kind (TMono m))
| MField cf -> Printf.sprintf "MField %s" cf.cf_name
| MType(t,_) -> Printf.sprintf "MType %s" (s_type_kind t)
| MEmptyStructure -> "MEmptyStructure"

let s_type_param s_type ttp =
let s = match (get_constraints ttp) with
Expand Down
1 change: 1 addition & 0 deletions src/core/tType.ml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ and tmono_constraint =
| MMono of tmono * string option
| MField of tclass_field
| MType of t * string option
| MEmptyStructure

and tmono_constraint_kind =
| CUnknown
Expand Down
11 changes: 6 additions & 5 deletions src/core/tUnification.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,20 @@ module Monomorph = struct
| MMono (m2,s) -> m2.tm_up_constraints <- (TMono m,s) :: m.tm_up_constraints
| _ -> ()

let constraint_of_type m name t = match follow t with
let constraint_of_type name t = match follow t with
| TMono m2 ->
[MMono(m2,name)]
| TAnon an when not (PMap.is_empty an.a_fields) ->
PMap.fold (fun cf l ->
(MField cf) :: l
) an.a_fields []
| TAnon _ ->
add_modifier m MOpenStructure;
[]
[MEmptyStructure]
| _ ->
[MType(t,name)]

let constrain_to_type m name t =
List.iter (add_down_constraint m) (constraint_of_type m name t)
List.iter (add_down_constraint m) (constraint_of_type name t)

(* Note: This function is called by printing and others and should thus not modify state. *)

Expand All @@ -152,12 +151,14 @@ module Monomorph = struct
List.iter check m2.tm_down_constraints
end
| Some t ->
List.iter (fun constr -> check constr) (constraint_of_type m2 name t)
List.iter (fun constr -> check constr) (constraint_of_type name t)
end;
| MField cf ->
fields := PMap.add cf.cf_name cf !fields;
| MType(t2,name) ->
DynArray.add types (t2,name)
| MEmptyStructure ->
is_open := true
in
List.iter check m.tm_down_constraints;
List.iter (function
Expand Down

0 comments on commit 4897bcb

Please sign in to comment.