%---------------------------------------------------------------------------% % vim: ft=mercury ts=4 sw=4 et wm=0 tw=0 %---------------------------------------------------------------------------% % % This program causes the compiler (rotd-2016-06-09) to abort with the % following: % % Uncaught Mercury exception: % Software Error: map.lookup: key not found % Key Type: int % Key Value: 1 % Value Type: hlds.hlds_pred.proc_info % %---------------------------------------------------------------------------% :- module bug410. :- interface. :- import_module io. :- pred main(io::di, io::uo) is det. %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% :- implementation. :- import_module bool. :- import_module char. :- import_module int. :- import_module list. :- import_module maybe. :- import_module random. :- import_module solutions. :- import_module string. :- import_module time. %---------------------------------------------------------------------------% main(!IO) :- clock(Time, !IO), random.init(Time, RNG0), FormIGen = form1_gen(0, 0, [], []), Gens = [FormIGen], list.length(Gens, NumGens), make_titles(NumGens, Gens, 30, [], _, RNG0, _, !IO). %---------------------------------------------------------------------------% :- type generator == pred(maybe(string), list(string), list(string), random.supply, random.supply). :- inst generator == (pred(out, in, out, in, out) is det). % There's a closing parenthesis missing here ---------------+ % | :- pred make_titles(int::in, list(generator)::in(list(generator), int::in, list(string)::in, list(string)::out, random.supply::in, random.supply::out, io::di, io::uo) is det. make_titles(NumGens, GenPreds, N, !Used, !RNG, !IO) :- ( if N < 0 then true else random.random(1, NumGens, NumGen, !RNG), list.det_index1(GenPreds, NumGen, GenPred), GenPred(MaybeTitle, !Used, !RNG), ( MaybeTitle = yes(Title), io.print_line(Title, !IO), make_titles(NumGens, GenPreds, N - 1, !Used, !RNG, !IO) ; MaybeTitle = no, make_titles(NumGens, GenPreds, N, !Used, !RNG, !IO) ) ). :- pred form1_gen(int::in, int::in, list(string)::in, list(string)::in, maybe(string)::out, list(string)::in, list(string)::out, random.supply::in, random.supply::out) is det. form1_gen(_, _, _, _, MaybeTitle, !Used, !RNG) :- MaybeTitle = yes("foo"). %---------------------------------------------------------------------------% :- end_module bug410. %---------------------------------------------------------------------------%