Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add warning if fv finds an invalidating model and decimals use 255 #1113

Merged
merged 3 commits into from
Jan 24, 2023

Conversation

rsoeldner
Copy link
Member

Addresses #1107 by adding a warning in case, an invalidating model is found which uses 255 decimal places. This indicates a precision underflow.

The following program

(module test GOVERNANCE
  (defcap GOVERNANCE() true)
  
  (defun get-refund:decimal (balance:decimal stakers:integer)
    @model [ (property  (> result 0.0))  ]
    
    (enforce (> balance 0.0) "balance must be non-negative")
    (enforce (> stakers 0) "stakers must be non-negative")

    (/ balance stakers)) )

(verify 'test)

will result in this output:
image

The warning is placed in the corresponding FV trace.

src-tool/Pact/Analyze/Model/Text.hs Outdated Show resolved Hide resolved
src-tool/Pact/Analyze/Model/Text.hs Outdated Show resolved Hide resolved
@rsoeldner rsoeldner merged commit 1c47ed8 into master Jan 24, 2023
@rsoeldner rsoeldner deleted the rsoeldner/fv-warn-decimal-precision branch January 24, 2023 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants