@@ -109,6 +109,7 @@ type error =
109
109
| Closing_self_type of class_signature
110
110
| Polymorphic_class_parameter
111
111
| Non_value_binding of string * Jkind.Violation .t
112
+ | Non_value_let_binding of string * Jkind .sort
112
113
113
114
exception Error of Location. t * Env. t * error
114
115
exception Error_forward of Location. error
@@ -1397,12 +1398,9 @@ and class_expr_aux cl_num val_env met_env virt self_scope scl =
1397
1398
(fun (loc , mode , sort ) ->
1398
1399
Typecore. escape ~loc ~env: val_env ~reason: Other mode;
1399
1400
if not (Jkind.Sort. (equate sort value))
1400
- then let viol = Jkind.Violation. of_ (Not_a_subjkind (
1401
- Jkind. of_sort_for_error ~why: Let_binding sort,
1402
- Jkind. value ~why: Class_let_binding ))
1403
- in
1401
+ then
1404
1402
raise (Error (loc, met_env,
1405
- Non_value_binding (Ident. name id, viol )))
1403
+ Non_value_let_binding (Ident. name id, sort )))
1406
1404
)
1407
1405
modes_and_sorts;
1408
1406
let path = Pident id in
@@ -2248,6 +2246,11 @@ let report_error env ppf = function
2248
2246
fprintf ppf
2249
2247
" @[Variables bound in a class must have layout value.@ %a@]"
2250
2248
(Jkind.Violation. report_with_name ~name: nm) err
2249
+ | Non_value_let_binding (nm , sort ) ->
2250
+ fprintf ppf
2251
+ " @[The types of variables bound by a 'let' in a class function@ \
2252
+ must have layout value. Instead, %s's type has layout %a.@]"
2253
+ nm Jkind.Sort. format sort
2251
2254
2252
2255
let report_error env ppf err =
2253
2256
Printtyp. wrap_printing_env ~error: true
0 commit comments