Skip to content

Commit 5e50edf

Browse files
authored
flambda-backend: Remove var_constraint (#1880)
* Remove [var_constraint], which was redundant * bootstrap
1 parent b1962fa commit 5e50edf

File tree

5 files changed

+5
-27
lines changed

5 files changed

+5
-27
lines changed

boot/ocamlc

-27.5 MB
Binary file not shown.

boot/ocamllex

-61 Bytes
Binary file not shown.

typing/jkind.ml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ module Sort = struct
4545

4646
let void = Const Void
4747
let value = Const Value
48-
4948
let float64 = Const Float64
5049

5150
let some_value = Some value
@@ -59,6 +58,7 @@ module Sort = struct
5958

6059
let new_var () = Var (ref None)
6160

61+
(* Post-condition: If the result is a [Var v], then [!v] is [None]. *)
6262
let rec get : t -> t = function
6363
| Const _ as t -> t
6464
| Var r as t -> begin match !r with
@@ -70,20 +70,6 @@ module Sort = struct
7070
end
7171
end
7272

73-
(* This is constant-time if [var] was just returned from a previous call to
74-
[get]. That's because [var] will always be [None] in that case.
75-
*)
76-
let var_constraint : var -> const option = fun r ->
77-
match !r with
78-
| None -> None
79-
| Some t -> begin
80-
match get t with
81-
| Const const -> Some const
82-
| Var { contents = None } -> None
83-
| Var _ ->
84-
Misc.fatal_error "[get] should return [Const _] or [Var None]"
85-
end
86-
8773
let default_value : t option = Some (Const Value)
8874
let default_void : t option = Some (Const Void)
8975
let default_float64 : t option = Some (Const Float64)
@@ -515,6 +501,7 @@ let sub_desc d1 d2 = match d1, d2 with
515501
| Var v1, Var v2 -> if v1 == v2 then Equal else Not_sub
516502
| Const _, Var _ | Var _, Const _ -> Not_sub
517503

504+
(* Post-condition: If the result is [Var v], then [!v] is [None]. *)
518505
let get_internal (lay : internal) : desc = match lay with
519506
| Any -> Const Any
520507
| Immediate -> Const Immediate

typing/jkind.mli

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ module Sort : sig
5050
(** A sort variable that can be unified during type-checking. *)
5151
type var
5252

53-
(** Return the concrete constraint placed on the variable. This check is
54-
constant-time if [var] was just returned from [Jkind.get].
55-
*)
56-
val var_constraint : var -> const option
57-
5853
(** Create a new sort variable that can be unified. *)
5954
val new_var : unit -> t
6055

typing/subst.ml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,7 @@ let with_additional_action (config : additional_action_config) s =
109109
| Const Immediate -> immediate
110110
| Const Immediate64 -> immediate64
111111
| Const Float64 -> float64
112-
| Var var -> begin
113-
match Jkind.Sort.var_constraint var with
114-
| Some Void -> void
115-
| Some Value -> value
116-
| Some Float64 -> float64
117-
| None -> raise(Error (loc, Unconstrained_jkind_variable))
118-
end
112+
| Var _ -> raise(Error (loc, Unconstrained_jkind_variable))
119113
in
120114
Prepare_for_saving prepare_jkind
121115
in
@@ -228,6 +222,8 @@ let newpersty desc =
228222
create_expr
229223
desc ~level:generic_level ~scope:Btype.lowest_level ~id:!new_id
230224

225+
(* CR layouts: remove this. While we're still developing, though, it might
226+
be nice to get the location of this kind of error. *)
231227
(* We use a ref instead of passing [loc] as an argument to [typexp]
232228
because the ref requires no modifications to the body of [typexp],
233229
reducing the chance of merge conflicts. This location is not critical --

0 commit comments

Comments
 (0)