File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ (* Example provided by Pierre Chambart and Guillaume Bury
2+ This example was produced to test cases where a variant
3+ can be unboxed but there isn't any existing variable that
4+ refers to the field of the block.
5+ However, it also triggered a few bugs in the join algorithm,
6+ fixed by PRs #327 and #329, so it is included here.
7+
8+ The goal here is to propagate enough information to remove
9+ the last assert false.
10+ The main issue was that the type for v was Top, for two reasons:
11+ - The fact that v is an alias to r was not correctly propagated,
12+ because its type was the result of joining an alias with Bottom
13+ (this is fixed by #327)
14+ - Even without the alias, the join should have expanded the type
15+ at the use site and found that it only had Foo (0) as possible tag,
16+ but because the expansion was done in the wrong environment no
17+ type was found and Top was returned instead.
18+ *)
19+
20+ type t =
21+ | Foo of int
22+ | Bar of string
23+
24+ let f r =
25+ let v =
26+ match r with
27+ | (Foo x' ) as res -> res
28+ | Bar _ -> raise Exit
29+ in
30+ let v' =
31+ if Sys. opaque_identity false then
32+ v
33+ else
34+ Foo 42
35+ in
36+ match v' with
37+ | Foo i -> i
38+ | Bar _ -> assert false
39+
You can’t perform that action at this time.
0 commit comments