Skip to content

Commit f91973f

Browse files
committed
make builtin dict type be a record with anyOtherField catch all
1 parent 8d7e395 commit f91973f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

jscomp/ml/predef.ml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ and ident_failure = ident_create_predef_exn "Failure"
112112
and ident_ok = ident_create_predef_exn "Ok"
113113
and ident_error = ident_create_predef_exn "Error"
114114

115+
and ident_anyOtherField = ident_create "anyOtherField"
116+
115117
and ident_js_error = ident_create_predef_exn "JsError"
116118
and ident_not_found = ident_create_predef_exn "Not_found"
117119

@@ -221,7 +223,16 @@ let common_initial_env add_type add_extension empty_env =
221223
{decl_abstr with
222224
type_params = [tvar];
223225
type_arity = 1;
224-
type_variance = [Variance.full]}
226+
type_variance = [Variance.full];
227+
type_kind =
228+
Type_record ([
229+
{ld_id = ident_anyOtherField;
230+
ld_attributes = [(Location.mknoloc "res.optional", Parsetree.PStr [])];
231+
ld_loc = Location.none;
232+
ld_mutable = Immutable; (* TODO(dict-pattern-matching) Should probably be mutable? *)
233+
ld_type = newgenty (Tconstr (path_option, [tvar], ref Mnil));
234+
}], Record_optional_labels [Ident.name ident_anyOtherField]);
235+
}
225236
and decl_uncurried =
226237
let tvar1, tvar2 = newgenvar(), newgenvar() in
227238
{decl_abstr with

0 commit comments

Comments
 (0)