Skip to content

Commit be1d4ed

Browse files
committed
sanity check not not allow true/false being redefined
1 parent 602a09d commit be1d4ed

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

jscomp/syntax/bs_ast_invariant.ml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ let emit_external_warnings : iterator=
107107
)
108108
| _ -> default_iterator.expr self a
109109
);
110-
label_declaration = (fun self lbl ->
110+
label_declaration = (fun self lbl ->
111111

112112
Ext_list.iter lbl.pld_attributes
113113
(fun attr ->
@@ -117,6 +117,14 @@ let emit_external_warnings : iterator=
117117
);
118118
default_iterator.label_declaration self lbl
119119
);
120+
constructor_declaration = (fun self ({pcd_name} as ctr) ->
121+
(match pcd_name.txt with
122+
| "false"
123+
| "true" ->
124+
Location.raise_errorf ~loc:pcd_name.loc "true/false can not be redefined "
125+
| _ -> ());
126+
default_iterator.constructor_declaration self ctr
127+
);
120128
value_description =
121129
(fun self v ->
122130
match v with

0 commit comments

Comments
 (0)