Skip to content

Commit

Permalink
Print warning recommending contract assumptions over assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-larraz committed Oct 30, 2023
1 parent 47d2dfb commit c53aba0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lustre/lustreAstNormalizer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ type error = [

type warning_kind =
| UnguardedPreWarning of A.expr
| UseOfAssertionWarning

let warning_message warning = match warning with
| UnguardedPreWarning expr -> "Unguarded pre in expression " ^ A.string_of_expr expr
| UseOfAssertionWarning ->
"Assertions are not checked; please consider using a contract assumption instead"

type warning = [
| `LustreAstNormalizerWarning of Lib.position * warning_kind
Expand Down Expand Up @@ -1047,6 +1050,7 @@ and normalize_contract info map items =
and normalize_equation info map = function
| Assert (pos, expr) ->
let nexpr, map, warnings = abstract_expr true info map true expr in
let warnings = mk_warning pos UseOfAssertionWarning :: warnings in
A.Assert (pos, nexpr), map, warnings
| Equation (pos, lhs, expr) ->
(* Need to track array indexes of the left hand side if there are any *)
Expand Down
1 change: 1 addition & 0 deletions src/lustre/lustreAstNormalizer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type error = [

type warning_kind =
| UnguardedPreWarning of LustreAst.expr
| UseOfAssertionWarning

type warning = [
| `LustreAstNormalizerWarning of Lib.position * warning_kind
Expand Down

0 comments on commit c53aba0

Please sign in to comment.