% mmc -O0 --deforestation -C deforest_bug.m % % Uncaught Mercury exception: % Software Error: ll_backend.code_gen: % predicate `ll_backend.code_gen.generate_goal'/5: % Unexpected: nondet model in det/semidet context :- module deforest_bug. :- interface. :- type bool ---> no ; yes. :- pred foo(bool, int). :- mode foo(in, out) is det. :- implementation. :- type maybe(T) ---> no ; yes(T). foo(B, X) :- bar(X0), ( if quux(B, no, _) then X = X0 else X = X0 ). :- pred bar(int). :- mode bar(out) is det. bar(0). :- pred quux(bool, maybe(int), int). :- mode quux(in, in, out) is semidet. quux(B, R, Q) :- ( B = yes ; R = yes(_) ), ( R = yes(Q) ; R = no, Q = 0 ).