@@ -1096,6 +1096,25 @@ let transl_declaration env sdecl (id, uid) =
1096
1096
decl, typ_shape
1097
1097
end
1098
1098
1099
+ (* Note [Typechecking unboxed versions of types]
1100
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1101
+ Unboxed versions are computed in three steps:
1102
+
1103
+ 1. In the temporary environment computed by [enter_type], all types get an
1104
+ unboxed version.
1105
+
1106
+ 2. After translating declarations, [derive_unboxed_versions] gives the
1107
+ [Record_boxed] records unboxed versions.
1108
+
1109
+ 3. But some of these [Record_boxed]s are a lie, and become
1110
+ [Record_float]/[Record_ufloat]/[Record_mixed] after [update_decls_jkind].
1111
+ As float records should not end up with unboxed versions, we then remove
1112
+ theirs in [remove_unboxed_versions].
1113
+
1114
+ After steps 2 and 3, the set of unboxed versions decreases, so we check for
1115
+ newly-unbound unboxed paths with [check_unboxed_paths].
1116
+ *)
1117
+
1099
1118
(* Record declarations with representation [Record_boxed] get an implicit
1100
1119
unboxed record stored in [type_unboxed_version]. If that record is also an
1101
1120
alias, so is its stored unboxed version. E.g. [type t = r = { i : int }]'s
@@ -1215,9 +1234,9 @@ let derive_unboxed_versions decls env =
1215
1234
id, { d with type_unboxed_version })
1216
1235
decls
1217
1236
1218
- (* Float and [@@ unboxed] records are typechecked as boxed records until
1219
- [update_decls_jkind], so their unboxed versions need to be removed
1220
- afterwards .
1237
+ (* Removes unboxed versions from type declarations not satisfying
1238
+ [gets_unboxed_version]. In practice, it is float records that lose their
1239
+ unboxed versions. See Note [Typechecking unboxed versions of types] .
1221
1240
1222
1241
Returns new decls and paths whose unboxed versions got removed. *)
1223
1242
let remove_unboxed_versions decls =
@@ -2056,6 +2075,7 @@ let update_decls_jkind env decls =
2056
2075
(id, decl, allow_any_crossing, update_decl_jkind env (Pident id) decl))
2057
2076
decls
2058
2077
2078
+ (* See Note [Typechecking unboxed versions of types]. *)
2059
2079
let check_unboxed_paths decls ~unboxed_version_banned =
2060
2080
(* We iterate on all subexpressions of the declaration to check "in depth"
2061
2081
that no non-existent unboxed version is used. *)
0 commit comments