mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-30 08:44:37 +00:00
Estimated hours taken: 1
Branches: main
Fix a bug in the following optimisation of model_non lambdas:
% Optimize a special case: replace
% `(pred(Y1, Y2, ...) is Detism :-
% p(X1, X2, ..., Y1, Y2, ...))'
% where `p' has determinism `Detism' with
% `p(X1, X2, ...)'
%
For the LLDS back-end the optimisation was also applied when `p' is model_det
but the lambda is model_non. However it was incorrectly applied for the
erlang grade as well.
compiler/lambda.m:
Don't apply the optimisation in the case above.
tests/hard_coded/Mmakefile:
tests/hard_coded/nondet_lambda.exp:
tests/hard_coded/nondet_lambda.m:
Add a test case.
24 lines
409 B
Mathematica
24 lines
409 B
Mathematica
:- module nondet_lambda.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
|
|
main(!IO) :-
|
|
% The compiler was incorrectly simplifying this to `F = bar' in the erlang
|
|
% grade.
|
|
F = (pred(X::out) is nondet :- bar(X)),
|
|
( F(Y) ->
|
|
io__write(Y, !IO),
|
|
io__write_string("\n", !IO)
|
|
;
|
|
true
|
|
).
|
|
|
|
:- pred bar(int).
|
|
:- mode bar(out) is det.
|
|
bar(42).
|