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

Panic: type cannot be demoted inf - inf #1696

Open
weaversa opened this issue Jul 2, 2024 · 3 comments
Open

Panic: type cannot be demoted inf - inf #1696

weaversa opened this issue Jul 2, 2024 · 3 comments

Comments

@weaversa
Copy link
Collaborator

weaversa commented Jul 2, 2024

Help...related to #1693.

f : {m, n} (n < m) => [m] -> [n]
f x = take x
Cryptol> f (zero : [inf]) : [inf]
cryptol: You have encountered a bug in Cryptol's implementation.
*** Please create an issue at https://github.com/GaloisInc/cryptol/issues

%< ---------------------------------------------------
  Revision:  UNKNOWN
  Branch:    UNKNOWN
  Location:  [Eval] evalTF
  Message:   type cannot be demoted
             inf - inf
CallStack (from HasCallStack):
  panic, called at src/Cryptol/Utils/Panic.hs:21:9 in cryptol-3.1.0.99-inplace:Cryptol.Utils.Panic
  panic, called at src/Cryptol/Backend/Monad.hs:410:17 in cryptol-3.1.0.99-inplace:Cryptol.Backend.Monad
  evalPanic, called at src/Cryptol/Eval/Type.hs:244:25 in cryptol-3.1.0.99-inplace:Cryptol.Eval.Type
%< ---------------------------------------------------
@weaversa
Copy link
Collaborator Author

weaversa commented Jul 2, 2024

take outside of a function seems to work just fine.

Cryptol> take (zero : [inf]) : [inf]
[False, False, False, False, False, ...]

yav added a commit that referenced this issue Jul 2, 2024
@yav
Copy link
Member

yav commented Jul 2, 2024

This is due to an incorrect simplification rule: a = ?x + b ~> ?x = a - b. This is only valid when b is finite, but this additional check was missing. PR #1697 fixes this, and under this PR the original definition of f is rejected, because there is no way to infer the back argument to pass to take.

@yav
Copy link
Member

yav commented Jul 2, 2024

I am looking into why take is working on its own. I suspect it is either another incorrect rule or, perhaps, we are somehow defaulting the back argument to 0.

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

No branches or pull requests

2 participants