summaryrefslogtreecommitdiff
path: root/typing
diff options
context:
space:
mode:
authorStephen Dolan <stephen.dolan@cl.cam.ac.uk>2017-05-12 14:09:06 +0100
committerStephen Dolan <stephen.dolan@cl.cam.ac.uk>2017-05-12 14:09:06 +0100
commita4ea78bd1987a9a121097be0aa3db622cbf1ad68 (patch)
tree4039edd6a18be70609dbc17cd27b2613ab12a3e5 /typing
parent93fdf397dc6196c19b566d2e50ff985e789210bf (diff)
downloadocaml-a4ea78bd1987a9a121097be0aa3db622cbf1ad68.tar.gz
Make (raise e) nonexpansive.
Test in typing-poly/poly.ml.
Diffstat (limited to 'typing')
-rw-r--r--typing/typecore.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/typing/typecore.ml b/typing/typecore.ml
index ea6727d9f4..d76710f1de 100644
--- a/typing/typecore.ml
+++ b/typing/typecore.ml
@@ -1616,8 +1616,16 @@ let rec is_nonexpansive exp =
is_nonexpansive_mod mexp && is_nonexpansive e
| Texp_pack mexp ->
is_nonexpansive_mod mexp
+ (* Computations which raise exceptions are nonexpansive, since (raise e) is equivalent
+ to (raise e; diverge), and a nonexpansive "diverge" can be produced using lazy values
+ or the relaxed value restriction. See GPR#1142 *)
| Texp_assert exp ->
is_nonexpansive exp
+ | Texp_apply (
+ { exp_desc = Texp_ident (_, _, {val_kind =
+ Val_prim {Primitive.prim_name = "%raise"}}) },
+ [Nolabel, Some e]) ->
+ is_nonexpansive e
| _ -> false
and is_nonexpansive_mod mexp =