|
|
@@ -188,11 +188,13 @@ let rec typecheck node =
|
|
|
| Const (BoolVal value, ann) ->
|
|
|
Const (BoolVal value, Type Bool :: ann)
|
|
|
| Const (IntVal value, ann) ->
|
|
|
- (* Do a bound check on integers (use Nativeint because default ints in
|
|
|
- * ocaml are 31- or 64-bit *)
|
|
|
+ (* Do a bound check on integers (use Int32 because default ints in ocaml
|
|
|
+ * are 31- or 63-bit *)
|
|
|
let cmpval = Nativeint.of_int value in
|
|
|
- if cmpval < Nativeint.min_int || cmpval > Nativeint.max_int then (
|
|
|
- raise (NodeError (node, "integer value out of range"))
|
|
|
+ let min = Nativeint.of_int32 Int32.min_int in
|
|
|
+ let max = Nativeint.of_int32 Int32.max_int in
|
|
|
+ if cmpval < min || cmpval > max then (
|
|
|
+ raise (NodeError (node, "integer value out of range (signed 32-bit)"))
|
|
|
);
|
|
|
Const (IntVal value, Type Int :: ann)
|
|
|
| Const (FloatVal value, ann) ->
|