Skip to content

Commit f39cacd

Browse files
Gustavo2622strub
authored andcommitted
Fix issue #905, improve error message on missing two sided memory
1 parent d672d43 commit f39cacd

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/ecTyping.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ type filter_error =
116116
| FE_InvalidIndex of int
117117
| FE_NoMatch
118118

119+
type goal_shape_error =
120+
| GSE_ExpectedTwoSided
121+
119122
type tyerror =
120123
| UniVarNotAllowed
121124
| FreeTypeVariables
@@ -180,6 +183,7 @@ type tyerror =
180183
| ProcAssign of qsymbol
181184
| PositiveShouldBeBeforeNegative
182185
| NotAnExpression of [`Unknown | `LL | `Pr | `Logic | `Glob | `MemSel]
186+
| UnexpectedGoalShape of goal_shape_error
183187

184188
(* -------------------------------------------------------------------- *)
185189
exception TyError of EcLocation.t * EcEnv.env * tyerror
@@ -3194,7 +3198,10 @@ and trans_form_or_pattern env mode ?mv ?ps ue pf tt =
31943198

31953199
map_ss_inv f_tuple res in
31963200

3197-
let ml, mr = oget (EcEnv.Memory.get_active_ts env) in
3201+
let ml, mr = match (EcEnv.Memory.get_active_ts env) with
3202+
| Some (ml, mr) -> ml, mr
3203+
| None -> tyerror f.pl_loc env (UnexpectedGoalShape GSE_ExpectedTwoSided)
3204+
in
31983205
let x1 = ss_inv_generalize_right (create ml) mr in
31993206
let x2 = ss_inv_generalize_left (create mr) ml in
32003207

src/ecTyping.mli

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ type filter_error =
108108
| FE_InvalidIndex of int
109109
| FE_NoMatch
110110

111+
112+
type goal_shape_error =
113+
| GSE_ExpectedTwoSided
114+
111115
type tyerror =
112116
| UniVarNotAllowed
113117
| FreeTypeVariables
@@ -172,6 +176,7 @@ type tyerror =
172176
| ProcAssign of qsymbol
173177
| PositiveShouldBeBeforeNegative
174178
| NotAnExpression of [`Unknown | `LL | `Pr | `Logic | `Glob | `MemSel]
179+
| UnexpectedGoalShape of goal_shape_error
175180

176181
exception TymodCnvFailure of tymod_cnv_failure
177182
exception TyError of EcLocation.t * env * tyerror

src/ecUserMessages.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ end = struct
226226
| FXE_SynCheckFailure ->
227227
msg "syntactic termination check failure"
228228

229+
let pp_gse_error _env fmt error =
230+
let msg = Format.fprintf fmt in
231+
match error with
232+
| GSE_ExpectedTwoSided ->
233+
msg "expected two sided goal"
234+
229235
let pp_tyerror env1 fmt error =
230236
let env = EcPrinting.PPEnv.ofenv env1 in
231237
let msg x = Format.fprintf fmt x in
@@ -551,6 +557,9 @@ end = struct
551557
end
552558
end
553559

560+
| UnexpectedGoalShape gse ->
561+
msg "unexpected goal shape %a" (pp_gse_error env) gse
562+
554563
let pp_restr_error env fmt (w, e) =
555564
let ppe = EcPrinting.PPEnv.ofenv env in
556565

0 commit comments

Comments
 (0)