Skip to content

Commit dd9bd93

Browse files
committed
add error messages on some call failures
When using call with invariant on procedures whose argument or return types do not match, we raised an exception without catching it. This adds an error message.
1 parent e74c002 commit dd9bd93

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/phl/ecPhlCall.ml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,25 @@ let mk_inv_spec (_pf : proofenv) env inv fl fr =
500500
let defl = EcEnv.Fun.by_xpath fl env in
501501
let defr = EcEnv.Fun.by_xpath fr env in
502502
let sigl, sigr = defl.f_sig, defr.f_sig in
503-
let testty =
504-
EcReduction.EqTest.for_type env sigl.fs_arg sigr.fs_arg
505-
&& EcReduction.EqTest.for_type env sigl.fs_ret sigr.fs_ret
503+
504+
let error s tl tr =
505+
let ppe = EcPrinting.PPEnv.ofenv env in
506+
tc_error _pf "@[The procedures do not have the same %s types:@]@;<2 2>\
507+
@[<v>Left side: @[<h>%a@]@,\
508+
Right side: @[<h>%a@]@]@;<2 0>\
509+
A full contract cannot be inferred; consider providing a full contract using@;<2 2>\
510+
call (: ...==> ...)@,"
511+
s
512+
(EcPrinting.pp_type ppe) tl
513+
(EcPrinting.pp_type ppe) tr
506514
in
507515

508-
if not testty then raise EqObsInError;
516+
if not (EcReduction.EqTest.for_type env sigl.fs_arg sigr.fs_arg)
517+
then error "argument" sigl.fs_arg sigr.fs_arg;
518+
519+
if not (EcReduction.EqTest.for_type env sigl.fs_ret sigr.fs_ret)
520+
then error "return" sigl.fs_ret sigr.fs_ret;
521+
509522
let eq_params =
510523
ts_inv_eqparams
511524
sigl.fs_arg sigl.fs_anames ml

0 commit comments

Comments
 (0)