Files
mercury/tests/valid/constraint_proof_bug.m
Fergus Henderson b477d2c585 Fix a bug reported by Dominique de Waleffe <ddw@miscrit.be>.
Estimated hours taken: 1.5

Fix a bug reported by Dominique de Waleffe <ddw@miscrit.be>.

compiler/typecheck.m:
	Fix a bug: it was not applying the type bindings to the constraint
	proof map.  This caused a map__lookup error in polymorphism.m when
	it tried to look up the constraints in the constraint proof map.

tests/valid/Mmakefile:
tests/valid/constraint_proof_bug.m:
tests/valid/constraint_proof_bug_lib.m:
	Add a regression test for the above-mentioned bug.
1999-07-22 17:14:52 +00:00

47 lines
1.1 KiB
Mathematica

:- module constraint_proof_bug.
:-interface.
:-import_module io.
:-pred main(io:state::di,io:state::uo) is det.
:- implementation.
:-import_module constraint_proof_bug_lib,io,string,require.
:-type service==string.
:-type prestationid==int.
:-type provider==int.
:-type bevent--->
prest(prestationid,date,code,provider)
; day(int,date)
; admit(date,service)
; discharge(date,service)
; transfer(date,service,service)
; wrong(date).
:-some [T] pred get_field(bevent,string,T) => constrainable(T).
:-mode get_field(in,in,out) is semidet.
get_field(Ev,Field,R) :-
Field="date" -> R=d(Dt),get_date_field(Ev,Dt)
;
Field="code" -> R=c(Cd),get_code_field(Ev,Cd)
;
error("No handler for this field").
:-pred get_date_field(bevent::in,date::out) is det.
get_date_field(prest(_,Dt,_,_),Dt).
get_date_field(day(_,Dt),Dt).
get_date_field(admit(Dt,_),Dt).
get_date_field(discharge(Dt,_),Dt).
get_date_field(transfer(Dt,_,_),Dt).
get_date_field(wrong(Dt),Dt).
:-pred get_code_field(bevent::in,code::out) is semidet.
get_code_field(prest(_,_,Cd,_),Cd).
main-->
print("hello world\n").