@@ -86,6 +86,7 @@ type error =
86
86
| Unpackable_local_modtype_subst of Path .t
87
87
| With_cannot_remove_packed_modtype of Path .t * module_type
88
88
| Toplevel_nonvalue of string * sort
89
+ | Strengthening_mismatch of Longident .t * Includemod .explanation
89
90
90
91
exception Error of Location. t * Env. t * error
91
92
exception Error_forward of Location. error
@@ -1472,18 +1473,23 @@ and transl_modtype_jane_syntax_aux ~loc env = function
1472
1473
| Jane_syntax.Module_type. Jmty_strengthen { mty ; mod_id } ->
1473
1474
let tmty = transl_modtype_aux env mty in
1474
1475
let path, md =
1475
- Env. lookup_module ~use: false ~loc mod_id.txt env
1476
+ Env. lookup_module ~use: false ~loc: mod_id.loc mod_id.txt env
1476
1477
in
1477
1478
let aliasable = not (Env. is_functor_arg path env) in
1478
- ignore
1479
- (Includemod. modtypes ~loc env
1480
- ~mark: Includemod. Mark_both md.md_type tmty.mty_type);
1481
- mkmty
1482
- (Tmty_strengthen (tmty, path, mod_id))
1483
- (Mty_strengthen (tmty.mty_type, path, Aliasability. aliasable aliasable))
1484
- env
1485
- loc
1486
- []
1479
+ try
1480
+ ignore
1481
+ (Includemod. modtypes ~loc env
1482
+ ~mark: Includemod. Mark_both md.md_type tmty.mty_type);
1483
+ mkmty
1484
+ (Tmty_strengthen (tmty, path, mod_id))
1485
+ (Mty_strengthen
1486
+ (tmty.mty_type, path, Aliasability. aliasable aliasable))
1487
+ env
1488
+ loc
1489
+ []
1490
+ with Includemod. Error explanation ->
1491
+ raise(Error (loc, env, Strengthening_mismatch (mod_id.txt, explanation)))
1492
+ ;
1487
1493
1488
1494
and transl_with ~loc env remove_aliases (rev_tcstrs ,sg ) constr =
1489
1495
let lid, with_info = match constr with
@@ -3661,6 +3667,14 @@ let report_error ~loc _env = function
3661
3667
Location. errorf ~loc
3662
3668
" @[Top-level module bindings must have layout value, but@ \
3663
3669
%s has layout@ %a.@]" id Sort. format sort
3670
+ | Strengthening_mismatch (lid , explanation ) ->
3671
+ let main = Includemod_errorprinter. err_msgs explanation in
3672
+ Location. errorf ~loc
3673
+ " @[<v>\
3674
+ @[In this strengthened module type, the type of %a@ \
3675
+ does not match the underlying type@]@ \
3676
+ %t@]"
3677
+ longident lid main
3664
3678
3665
3679
let report_error env ~loc err =
3666
3680
Printtyp. wrap_printing_env ~error: true env
0 commit comments