Skip to content

Commit

Permalink
Merge pull request #193 from marcoeilers/non_positive_fold
Browse files Browse the repository at this point in the history
Add error message for fold/unfold with non-positive permissions
  • Loading branch information
marcoeilers authored May 28, 2024
2 parents 8e85db3 + 76ae221 commit d14145a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/nagini_translation/lib/errors/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
lambda n: 'Divisor {} might be zero.'.format(pprint(n)),
'negative.permission':
lambda n: 'Fraction {} might be negative.'.format(pprint(n)),
'permission.not.positive':
lambda n: 'Fraction {} might not be positive'.format(pprint(n)),
'insufficient.permission':
lambda n: ('There might be insufficient permission to '
'access {}.').format(pprint(n)),
Expand Down Expand Up @@ -203,6 +205,7 @@
'receiver.null': 'Receiver might be null.',
'division.by.zero': 'Divisor might be zero.',
'negative.permission': 'Fraction might be negative.',
'permission.not.positive': 'Fraction might not be positive.',
'insufficient.permission': 'There might be insufficient permission.',
'termination_measure.non_positive': 'Termination measure might be non-positive.',
'measure.non_decreasing': 'Termination measure might not be smaller.',
Expand Down
12 changes: 11 additions & 1 deletion tests/functional/verification/test_predicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@ def main_6() -> int:
s = Super(34, 99)
Fold(other_pred(s))
#:: ExpectedOutput(assignment.failed:insufficient.permission)
return Unfolding(some_pred(s, 34, 34), s.field3)
return Unfolding(some_pred(s, 34, 34), s.field3)


@Predicate
def pure(i: int) -> bool:
return i > 0


def previously_unsound() -> None:
#:: ExpectedOutput(unfold.failed:permission.not.positive)
Unfold(Acc(pure(-5), 0/1))

0 comments on commit d14145a

Please sign in to comment.