File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ type error =
49
49
| Unbound_type_var_ext of type_expr * extension_constructor
50
50
| Varying_anonymous
51
51
| Val_in_structure
52
+ | InvalidAttribute of string
52
53
| Bad_immediate_attribute
53
54
| Bad_unboxed_attribute of string
54
55
| Boxed_and_unboxed
@@ -295,6 +296,20 @@ let make_constructor env type_path type_params sargs sret_type =
295
296
*)
296
297
297
298
let transl_declaration ~type_record_as_object ~untagged_wfc env sdecl id =
299
+ (* Check for @notUndefined attribute *)
300
+ let has_not_undefined =
301
+ List. exists (fun ({txt} , _ ) -> txt = " notUndefined" ) sdecl.ptype_attributes
302
+ in
303
+ (if has_not_undefined then
304
+ match (sdecl.ptype_kind, sdecl.ptype_manifest) with
305
+ | Ptype_abstract , None -> ()
306
+ | _ ->
307
+ raise
308
+ (Error
309
+ ( sdecl.ptype_loc,
310
+ InvalidAttribute
311
+ " @notUndefined can only be used on abstract types" )));
312
+
298
313
(* Bind type parameters *)
299
314
reset_type_variables () ;
300
315
Ctype. begin_def () ;
@@ -2090,6 +2105,7 @@ let report_error ppf = function
2090
2105
" The field @{<info>%s@} is defined several times in this record. Fields \
2091
2106
can only be added once to a record."
2092
2107
s
2108
+ | InvalidAttribute msg -> fprintf ppf " %s" msg
2093
2109
| Duplicate_label (s , Some record_name ) ->
2094
2110
fprintf ppf
2095
2111
" The field @{<info>%s@} is defined several times in the record \
You can’t perform that action at this time.
0 commit comments