Software error: mode check fails when repeated

Fergus Henderson fjh at cs.mu.oz.au
Sun Aug 24 06:58:27 AEST 1997


Hi,

The bug below is due to the fact that the HLDS representation of
`higher_order_call' does not contain an is_pred_or_func indicator.
This means that when it tries to re-modecheck a higher-order function
call, it thinks it is a higher-order predicate call, and thus complains.

I seem to recall that someone (Andrew?) had a patch for this?
If so, could they please post it?

Philip Dart, you wrote:
> Compiling the program below gives a software error after
> a correct mode error message.

Actually it is after an incorrect mode error message.

> =================================== CUT HERE ===================================
> :- module sequp.
> 
> :- interface.
> :- import_module io.
> % :- pred main(io__state::di, io__state::uo) is det.
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> :- implementation.
> 
> :- import_module string.
> 
> :- type maybe(T) ---> yes(T) ; no.
> :- type code == int.
> :- type qty == int.
> :- type stock ---> stock(code, qty).
> % :- type stocks ---> list(stock).
> :- type iostocks ---> ios(io__state, stocks).
> :- type stocks
> 	--->	[]
> 	;	[stock  | stocks]
> 	;	closure(func(io__state) = iostocks)
> 	.
> 
> :- inst iostocks = unique(ios(unique, stocks)).
> :- inst stocks =
> 	bound(	[]
> 	;	[ground | stocks]
> 	;	closure(func(di) = is_out is det)
> 	).
> 
> :- mode is_in  ::  di(iostocks).
> :- mode is_out :: out(iostocks).
> 
> :- func putStocks(iostocks) = io__state.
> :- mode putStocks(is_in) = uo is det.
> putStocks(ios(IO, [])) = IO.
> putStocks(ios(IO, [S | T])) = putStocks(ios(IO1, T)) :-
> 	outStock(S, IO, IO1).
> putStocks(ios(IO, closure(Func))) = putStocks(apply(Func, IO)).
> 
> :- pred outStock(stock::in, io__state::di, io__state::uo) is det.
> outStock(stock(C, Q)) -->
> %	io__format("%i %i\n", [i(C), i(Q)]).
> 	io__write_int(C),
> 	io__write_char(' '),
> 	io__write_int(Q),
> 	io__nl.
> 
> :- func getStocks(io__state) = iostocks.
> :- mode getStocks(di) = is_out is det.
> getStocks(S0) = ios(S, Stocks) :-
> 	tokenize(MStock, S0, S),
> 	( MStock = no, Stocks = []
> 	; MStock = yes(Stock), Stocks = [Stock | closure(getStocks)]
> 	).
> 
> :- pred tokenize(maybe(stock)::out, io__state::di, io__state::uo) is det.
> tokenize(S) -->
> 	io__read_line(CL0),
> 	{ (CL0 = ok(CL),
> 		string__from_char_list(CL, Line),
> 		string__sub_string_search(Line, " ", Index),
> 		string__split(Line, Index, Left, Right0),
> 		string__first_char(Right0, _, Right),
> 		string__to_int(Left, Code),
> 		string__to_int(Right, Qty)) ->
> 		S = yes(stock(Code, Qty))
> 	;	S = no
> 	}.
> 
> 


-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list