@@ -46,20 +46,22 @@ and ident_string = ident_create "string"
46
46
and ident_extension_constructor = ident_create " extension_constructor"
47
47
and ident_floatarray = ident_create " floatarray"
48
48
49
+ and ident_unknown = ident_create " unknown"
50
+
49
51
type test =
50
52
| For_sure_yes
51
53
| For_sure_no
52
54
| NA
53
55
54
56
let type_is_builtin_path_but_option (p : Path.t ) : test =
55
57
match p with
56
- | Pident {Ident. stamp} ->
58
+ | Pident {stamp} ->
57
59
if
58
- stamp > = ident_int.Ident. stamp
59
- && stamp < = ident_floatarray.Ident. stamp
60
+ stamp > = ident_int.stamp
61
+ && stamp < = ident_floatarray.stamp
60
62
then
61
- if (stamp = ident_option.Ident. stamp)
62
- || (stamp = ident_unit.Ident. stamp) then
63
+ if (stamp = ident_option.stamp)
64
+ || (stamp = ident_unit.stamp) then
63
65
For_sure_no
64
66
else For_sure_yes
65
67
else NA
@@ -80,6 +82,8 @@ and path_option = Pident ident_option
80
82
and path_int64 = Pident ident_int64
81
83
and path_lazy_t = Pident ident_lazy_t
82
84
and path_string = Pident ident_string
85
+
86
+ and path_unkonwn = Pident ident_unknown
83
87
and path_extension_constructor = Pident ident_extension_constructor
84
88
and path_floatarray = Pident ident_floatarray
85
89
@@ -98,35 +102,36 @@ and type_option t = newgenty (Tconstr(path_option, [t], ref Mnil))
98
102
and type_int64 = newgenty (Tconstr (path_int64, [] , ref Mnil ))
99
103
and type_lazy_t t = newgenty (Tconstr (path_lazy_t, [t], ref Mnil ))
100
104
and type_string = newgenty (Tconstr (path_string, [] , ref Mnil ))
105
+
106
+ and type_unknown = newgenty (Tconstr (path_unkonwn, [] , ref Mnil ))
101
107
and type_extension_constructor =
102
108
newgenty (Tconstr (path_extension_constructor, [] , ref Mnil ))
103
109
and type_floatarray = newgenty (Tconstr (path_floatarray, [] , ref Mnil ))
104
110
105
111
let ident_match_failure = ident_create_predef_exn " Match_failure"
106
- and ident_out_of_memory = ident_create_predef_exn " Out_of_memory "
112
+
107
113
and ident_invalid_argument = ident_create_predef_exn " Invalid_argument"
108
114
and ident_failure = ident_create_predef_exn " Failure"
115
+
116
+ and ident_js_error = ident_create_predef_exn " JsError"
109
117
and ident_not_found = ident_create_predef_exn " Not_found"
110
- and ident_sys_error = ident_create_predef_exn " Sys_error "
118
+
111
119
and ident_end_of_file = ident_create_predef_exn " End_of_file"
112
120
and ident_division_by_zero = ident_create_predef_exn " Division_by_zero"
113
- and ident_stack_overflow = ident_create_predef_exn " Stack_overflow "
114
- and ident_sys_blocked_io = ident_create_predef_exn " Sys_blocked_io "
121
+
122
+
115
123
and ident_assert_failure = ident_create_predef_exn " Assert_failure"
116
124
and ident_undefined_recursive_module =
117
125
ident_create_predef_exn " Undefined_recursive_module"
118
126
119
127
let all_predef_exns = [
120
128
ident_match_failure;
121
- ident_out_of_memory;
122
129
ident_invalid_argument;
123
130
ident_failure;
131
+ ident_js_error;
124
132
ident_not_found;
125
- ident_sys_error;
126
133
ident_end_of_file;
127
134
ident_division_by_zero;
128
- ident_stack_overflow;
129
- ident_sys_blocked_io;
130
135
ident_assert_failure;
131
136
ident_undefined_recursive_module;
132
137
]
@@ -167,6 +172,8 @@ and ident_nil = ident_create "[]"
167
172
and ident_cons = ident_create " ::"
168
173
and ident_none = ident_create " None"
169
174
and ident_some = ident_create " Some"
175
+
176
+ and ident_ctor_unknown = ident_create " Unknown"
170
177
let common_initial_env add_type add_extension empty_env =
171
178
let decl_bool =
172
179
{decl_abstr with
@@ -200,6 +207,20 @@ let common_initial_env add_type add_extension empty_env =
200
207
type_arity = 1 ;
201
208
type_kind = Type_variant ([cstr ident_none []; cstr ident_some [tvar]]);
202
209
type_variance = [Variance. covariant]}
210
+ and decl_unknown =
211
+ let tvar = newgenvar () in
212
+ {decl_abstr with
213
+ type_params = [] ;
214
+ type_arity = 0 ;
215
+ type_kind = Type_variant ([ {
216
+ cd_id = ident_ctor_unknown;
217
+ cd_args = Cstr_tuple [tvar];
218
+ cd_res = Some type_unknown;
219
+ cd_loc = Location. none;
220
+ cd_attributes = []
221
+ }]);
222
+ type_unboxed = Types. unboxed_true_default_false
223
+ }
203
224
and decl_lazy_t =
204
225
let tvar = newgenvar() in
205
226
{decl_abstr with
@@ -222,13 +243,10 @@ let common_initial_env add_type add_extension empty_env =
222
243
in
223
244
add_extension ident_match_failure
224
245
[newgenty (Ttuple [type_string; type_int; type_int])] (
225
- add_extension ident_out_of_memory [] (
226
- add_extension ident_stack_overflow [] (
227
246
add_extension ident_invalid_argument [type_string] (
247
+ add_extension ident_js_error [type_unknown] (
228
248
add_extension ident_failure [type_string] (
229
249
add_extension ident_not_found [] (
230
- add_extension ident_sys_blocked_io [] (
231
- add_extension ident_sys_error [type_string] (
232
250
add_extension ident_end_of_file [] (
233
251
add_extension ident_division_by_zero [] (
234
252
add_extension ident_assert_failure
@@ -245,11 +263,12 @@ let common_initial_env add_type add_extension empty_env =
245
263
add_type ident_unit decl_unit (
246
264
add_type ident_bool decl_bool (
247
265
add_type ident_float decl_abstr (
266
+ add_type ident_unknown decl_unknown(
248
267
add_type ident_string decl_abstr (
249
268
add_type ident_int decl_abstr_imm (
250
269
add_type ident_extension_constructor decl_abstr (
251
270
add_type ident_floatarray decl_abstr (
252
- empty_env)))))))))))))))))))))))))
271
+ empty_env)))))))))))))))))))))))
253
272
254
273
let build_initial_env add_type add_exception empty_env =
255
274
let common = common_initial_env add_type add_exception empty_env in
@@ -263,10 +282,10 @@ let build_initial_env add_type add_exception empty_env =
263
282
264
283
let builtin_values =
265
284
List. map (fun id -> Ident. make_global id; (Ident. name id, id))
266
- [ident_match_failure; ident_out_of_memory; ident_stack_overflow;
285
+ [ident_match_failure;
267
286
ident_invalid_argument;
268
- ident_failure; ident_not_found; ident_sys_error; ident_end_of_file;
269
- ident_division_by_zero; ident_sys_blocked_io;
287
+ ident_failure; ident_js_error; ident_not_found; ident_end_of_file;
288
+ ident_division_by_zero;
270
289
ident_assert_failure; ident_undefined_recursive_module ]
271
290
272
291
(* Start non-predef identifiers at 1000. This way, more predefs can
0 commit comments