Skip to content

Commit 1397fe3

Browse files
committed
Add more fixes
1 parent 3cd1fa0 commit 1397fe3

File tree

8 files changed

+26
-20
lines changed

8 files changed

+26
-20
lines changed

examples/exception.ec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ op p2: int -> bool.
88

99
module M' ={
1010
proc truc (x:int) : int = {
11-
raise (! p1 x \/ ! p2 x) assume;
11+
ensure (! p1 x \/ ! p2 x) assume;
1212
if (!p1 x \/ !p2 x) { raise assert;}
1313
return x;
1414
}
@@ -46,7 +46,7 @@ exception e3.
4646

4747
module M ={
4848
proc f1 (x:int) : int = {
49-
raise (x <> 3) e1;
49+
ensure (x <> 3) e1;
5050
x <- 5;
5151
return x;
5252
}

src/ecLexer.mll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"match" , MATCH ; (* KW: prog *)
5454
"for" , FOR ; (* KW: prog *)
5555
"while" , WHILE ; (* KW: prog *)
56-
"raise" , RAISE ; (* KW: prog *)
56+
"ensure" , ENSURE ; (* KW: prog *)
57+
"raise" , RAISE ; (* KW: prog *)
5758
"return" , RETURN ; (* KW: prog *)
5859
"res" , RES ; (* KW: prog *)
5960
"equiv" , EQUIV ; (* KW: prog *)

src/ecParser.mly

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@
384384
%token AMP
385385
%token APPLY
386386
%token AS
387+
%token ENSURE
387388
%token RAISE
388389
%token ASSUMPTION
389390
%token ASYNC
@@ -1361,8 +1362,11 @@ base_instr:
13611362
| f=loc(fident) LPAREN es=loc(plist0(expr, COMMA)) RPAREN
13621363
{ PScall (None, f, es) }
13631364

1364-
| RAISE e=paren(expr)? x=qident
1365-
{ PSraise (x, e) }
1365+
| ENSURE e=paren(expr) x=qident
1366+
{ PSraise (x, Some e) }
1367+
1368+
| RAISE x=qident
1369+
{ PSraise (x, None) }
13661370

13671371
instr:
13681372
| bi=base_instr SEMICOLON
@@ -2551,15 +2555,11 @@ conseq_xt:
25512555
| UNDERSCORE COLON cmp=hoare_bd_cmp? bd=sform
25522556
{ (None, None, None), Some (CQI_bd (cmp, bd)) }
25532557

2554-
call_epost:
2555-
| empty { ([],None) }
2556-
| c=epostl_xt { c }
2557-
25582558
call_info:
2559-
| f1=form LONGARROW f2=form poe=call_epost { CI_spec (f1, f2, poe) }
2560-
| f=form { CI_inv (f) }
2561-
| bad=form COMMA p=form { CI_upto (bad,p,None) }
2562-
| bad=form COMMA p=form COMMA q=form { CI_upto (bad,p,Some q) }
2559+
| f1=form LONGARROW f2=form poe=conseq_epost { CI_spec (f1, f2, poe) }
2560+
| f=form { CI_inv (f) }
2561+
| bad=form COMMA p=form { CI_upto (bad,p,None) }
2562+
| bad=form COMMA p=form COMMA q=form { CI_upto (bad,p,Some q) }
25632563

25642564
tac_dir:
25652565
| BACKS { Backs }

src/ecParsetree.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ and pspattern = unit
544544
type excep_spec_preds = ((pqsymbol * pformula) list * pformula option)
545545

546546
type call_info =
547-
| CI_spec of (pformula * pformula * excep_spec_preds)
547+
| CI_spec of (pformula * pformula * excep_spec_preds option)
548548
| CI_inv of pformula
549549
| CI_upto of (pformula * pformula * pformula option)
550550

src/phl/ecPhlCall.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ let mk_inv_spec (_pf : proofenv) env inv fl fr =
422422
let post = map_ts_inv2 f_and eq_res inv in
423423
f_equivF pre fl fr post
424424

425+
let ensure_none_poe tc poe =
426+
if not (is_none poe) then tc_error !!tc "exception are not supported"
425427

426428
let process_call side info tc =
427429
let process_spec_2 tc side pre post =
@@ -569,9 +571,11 @@ let process_call side info tc =
569571
let _, concl = FApi.tc1_flat tc in
570572
match concl.f_node with
571573
| FhoareS _ ->
574+
let poe = odfl ([],None) poe in
572575
process_spec_1 tc side pre post poe
573576
| _ ->
574-
process_spec_2 tc side pre post
577+
ensure_none_poe tc poe;
578+
process_spec_2 tc side pre post
575579
end
576580

577581
| CI_inv inv ->
@@ -647,7 +651,8 @@ let process_call_concave (fc, info) tc =
647651

648652
let process_cut tc info =
649653
match info with
650-
| CI_spec (pre, post, ([],None)) ->
654+
| CI_spec (pre, post, poe) ->
655+
ensure_none_poe tc poe;
651656
let ty,fmake = process_spec tc in
652657
let _, pre = TTC.tc1_process_Xhl_form tc ty pre in
653658
let _, post = TTC.tc1_process_Xhl_form tc ty post in

src/phl/ecPhlEager.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ let process_fun_abs info eqI tc =
603603
let process_call info tc =
604604
let process_cut info =
605605
match info with
606-
| EcParsetree.CI_spec (fpre, fpost, ([],None)) ->
606+
| EcParsetree.CI_spec (fpre, fpost, None) ->
607607
let env, hyps, _ = FApi.tc1_eflat tc in
608608
let es = tc1_as_equivS tc in
609609

src/phl/ecPhlUpto.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ let rec check_bad_true env bad s =
6262
| Smatch(_,bs) ->
6363
let check_branch (_, s) = check_bad_true env bad s.s_node in
6464
List.iter (check_branch) bs
65-
| Sraise _ -> assert false
65+
| Sraise _ -> tacuerror "exception are not supported"
6666
| Sabstract _ -> ()
6767
end;
6868
check_bad_true env bad c
@@ -142,7 +142,7 @@ and i_upto env alpha bad i1 i2 =
142142
with E.NotConv -> false
143143
end
144144

145-
| Sraise e1, Sraise e2 -> EcPath.p_equal e1 e2
145+
| Sraise _, Sraise _ -> tacuerror "exception are not supported"
146146

147147
| Sabstract id1, Sabstract id2 ->
148148
EcIdent.id_equal id1 id2

src/phl/ecPhlWhile.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let while_info env e s =
4242
let f = EcEnv.NormMp.norm_xfun env f in
4343
(w, r, Sx.add f c)
4444

45-
| Sraise _ -> assert false
45+
| Sraise _ -> tacuerror "exception are not supported";
4646

4747
| Sabstract id ->
4848
let add_pv x (pv,ty) = PV.add env pv ty x in

0 commit comments

Comments
 (0)