File tree Expand file tree Collapse file tree 3 files changed +21
-31
lines changed Expand file tree Collapse file tree 3 files changed +21
-31
lines changed Original file line number Diff line number Diff line change @@ -56,11 +56,26 @@ open Ast_helper
56
56
| _ -> result in
57
57
aux ty *)
58
58
59
+ let is_builtin_rank0_type txt =
60
+ match txt with
61
+ | " int"
62
+ | " char"
63
+ | " bytes"
64
+ | " float"
65
+ | " bool"
66
+ | " unit"
67
+ | " exn"
68
+ | " int32"
69
+ | " int64"
70
+ | "string" -> true
71
+ | _ -> false
72
+
59
73
let is_unit (ty : t ) =
60
74
match ty.ptyp_desc with
61
75
| Ptyp_constr ({txt =Lident "unit" } , [] ) -> true
62
76
| _ -> false
63
77
78
+
64
79
(* let is_array (ty : t) =
65
80
match ty.ptyp_desc with
66
81
| Ptyp_constr({txt =Lident "array"}, [_]) -> true
Original file line number Diff line number Diff line change @@ -29,13 +29,10 @@ type t = Parsetree.core_type
29
29
30
30
val lift_option_type : t -> t
31
31
32
- (* val replace_result : t -> t -> t *)
33
-
34
- (* val opt_arrow: Location.t -> string -> t -> t -> t *)
35
-
36
32
val is_unit : t -> bool
37
- (* val is_array : t -> bool *)
38
33
34
+ val is_builtin_rank0_type :
35
+ string -> bool
39
36
40
37
(* * return a function type
41
38
[from_labels ~loc tyvars labels]
@@ -52,11 +49,6 @@ val make_obj :
52
49
53
50
val is_user_option : t -> bool
54
51
55
- (* val is_user_bool : t -> bool
56
-
57
- val is_user_int : t -> bool *)
58
-
59
-
60
52
61
53
(* *
62
54
returns 0 when it can not tell arity from the syntax
Original file line number Diff line number Diff line change @@ -117,27 +117,10 @@ let emit_external_warnings : iterator=
117
117
super with
118
118
type_declaration = (fun self ptyp ->
119
119
let txt = ptyp.ptype_name.txt in
120
- (match txt with
121
- | " int"
122
- | " char"
123
- | " bytes"
124
- | " float"
125
- | " bool"
126
- | " unit"
127
- | " exn"
128
- | " int32"
129
- | " int64"
130
- | " string"
131
- (* not adding parametric types yet
132
- | "array"
133
- | "list"
134
- | "option"
135
- *)
136
- ->
137
- Location. raise_errorf ~loc: ptyp.ptype_loc
138
- " built-in type `%s` can not be redefined " txt
139
- | _ -> ()
140
- );
120
+ if Ast_core_type. is_builtin_rank0_type txt then
121
+ Location. raise_errorf ~loc: ptyp.ptype_loc
122
+ " built-in type `%s` can not be redefined " txt
123
+ ;
141
124
super.type_declaration self ptyp
142
125
);
143
126
attribute = (fun _ attr -> warn_unused_attribute attr);
You can’t perform that action at this time.
0 commit comments