mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 03:43:51 +00:00
Estimated hours taken: 2 Fix a bug in compiler/common.m triggered by an interaction between the removal of unnecessary explicit quantifications and the method used to avoid increasing the number of variables stored on the stack across calls. compiler/common.m: Always produce all outputs of a unification when optimizing it away - any unneccessary assignments will be removed by another pass of simplification. Don't optimize constructions and deconstructions of partially instantiated variables - in the case of deconstructions the optimization does not handle bidirectional data flow properly. This case is difficult to test because the current mode analyser disallows most of the potential test cases. tests/valid/Mmakefile: tests/valid/common_struct_bug.m: Test case.
41 lines
754 B
Mathematica
41 lines
754 B
Mathematica
% The compiler of 26/10/1999 aborted in code generation (_Var12 not found)
|
|
% on this test case due to a bug in common structure elimination.
|
|
%
|
|
:- module common_struct_bug.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- type my_list(T)
|
|
---> cons(data :: T, next :: my_list(T))
|
|
; nil
|
|
.
|
|
|
|
:- implementation.
|
|
|
|
main(IO0, IO) :-
|
|
List0_4 = cons(Var16, Var17),
|
|
Var16 = 1,
|
|
Var17 = cons(Var18, Var19),
|
|
Var18 = 2,
|
|
Var19 = cons(Var20, Var21),
|
|
Var20 = 3,
|
|
Var21 = nil,
|
|
some [] (
|
|
List0_4 = cons(_Var12, Var14),
|
|
some [] (
|
|
Var14 = cons(_, Var57),
|
|
Var15 = cons(Var13, Var57)
|
|
),
|
|
some [] (
|
|
List0_4 = cons(Var58, _),
|
|
List1_5 = cons(Var58, Var15)
|
|
)
|
|
),
|
|
Var13 = 4,
|
|
io__write(List1_5, IO0, IO).
|
|
|