mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 03:13:40 +00:00
Estimated hours taken: 1.5 Fix a determinism analysis abort which was caused by det_analysis.m not updating the instmap to include the initial insts of the lambda variables before processing a lambda goal. This problem was also present in cse_detection.m and simplify.m. tests/valid/Mmake tests/valid/lambda_instmap_bug.m Regression test.
37 lines
853 B
Mathematica
37 lines
853 B
Mathematica
% Regression test for a case where cse_detection.m, det_analysis.m
|
|
% and simplify.m were not updating the instmap before processing
|
|
% a lambda expression, causing an abort in determinism analysis.
|
|
:- module lambda_instmap_bug.
|
|
|
|
:- interface.
|
|
|
|
:- import_module set, std_util.
|
|
|
|
:- type instr == pair(instruction, string).
|
|
|
|
:- type instruction
|
|
---> clear(int)
|
|
; drop(int)
|
|
; join(int, int, int).
|
|
|
|
:- pred detect_streams(set(int), list(instr), list(instr)).
|
|
:- mode detect_streams(in, in, out) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module list.
|
|
|
|
detect_streams(Streams, Instrs0, Instrs) :-
|
|
|
|
% Don't attempt to clear or drop streams.
|
|
IsNotStreamClear =
|
|
lambda([Instr::in] is semidet, (
|
|
\+ (
|
|
( Instr = clear(Rel) - _
|
|
; Instr = drop(Rel) - _
|
|
),
|
|
set__member(Rel, Streams)
|
|
)
|
|
)),
|
|
list__filter(IsNotStreamClear, Instrs0, Instrs).
|