Skip to content

Commit 8bbe689

Browse files
committed
Fix bug in lazy pattern matching
In some situations (i.e. with specialization), flambda2 might propagate too much information. In the situation of a branch where a lazy (whose definition by a make_block is seen by flambda2) is shortcut, and then directly used as an integer (because the lazy wraps an enum/variant), flambda2 might consider the branch as dead code, since the result of a make_block (the lazy value) is used as an integer. This is obviously not correct since the lazy value can be shortcut. The fix is to add some opaque so that flambda2 does not propagate the information from the make_block to the branch.
1 parent c40a123 commit 8bbe689

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lambda/matching.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,7 @@ let inline_lazy_force_cond arg pos loc =
21302130
( Strict,
21312131
Lambda.layout_lazy,
21322132
idarg,
2133-
arg,
2133+
Lprim (Popaque Lambda.layout_lazy, [arg], loc),
21342134
Llet
21352135
( Alias,
21362136
Lambda.layout_int,

0 commit comments

Comments
 (0)