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

SAWCore term mysteriously goes out of scope if given a certain type #1348

Open
RyanGlScott opened this issue Jun 21, 2021 · 5 comments
Open
Labels
topics: error-handling Issues involving the way SAW responds to an error condition topics: error-messages Issues involving the messages SAW produces on error type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use
Milestone

Comments

@RyanGlScott
Copy link
Contributor

For some reason, SAW accepts this program:

let identity = parse_core "\\(x : Integer) -> x";
prove_print z3 {{ \x -> identity x == x }};

But it does not accept it if identity is given a slightly different type:

let identity = parse_core "\\(x : Nat) -> x";
prove_print z3 {{ \x -> identity x == x }};
[15:43:59.027] Loading file "/home/rscott/Documents/Hacking/SAW/Bug.saw"
[15:43:59.035] Cryptol error:
[error] at /home/rscott/Documents/Hacking/SAW/Bug.saw:2:25--2:33
    Value not in scope: identity

I'm not sure if this is intended to work or not, but if not, the error message doesn't indicate why.

@RyanGlScott RyanGlScott added the topics: error-messages Issues involving the messages SAW produces on error label Jun 21, 2021
@RyanGlScott
Copy link
Contributor Author

In case it's important, I'm using SAW at commit e870373 in #1348 (comment). If I use the saw-0.8 release, it panics:

[15:45:11.894] Loading file "/home/rscott/Documents/Hacking/SAW/Bug.saw"
[15:45:11.894] You have encountered a bug in cryptol-saw-core's implementation.
*** Please create an issue at https://github.com/GaloisInc/saw-core/issues

%< --------------------------------------------------- 
  Revision:  e4c59543fc7520d6cfa3d44b0602a3274685b35d
  Branch:    HEAD
  Location:  scCryptolType
  Message:   scCryptolType: unsupported type (x : Prelude.Nat)
-> Prelude.Nat
CallStack (from HasCallStack):
  panic, called at src/Verifier/SAW/Cryptol/Panic.hs:13:9 in cryptol-saw-core-0.1-inplace:Verifier.SAW.Cryptol.Panic
  panic, called at src/Verifier/SAW/Cryptol.hs:1608:13 in cryptol-saw-core-0.1-inplace:Verifier.SAW.Cryptol
%< ---------------------------------------------------

@robdockins
Copy link
Contributor

This was changed recently by #1336. Basically, the issue is that Nat -> Nat doesn't correspond to any Cryptol type. This used to panic, as you can see. Now, SAWCore terms that don't have types that can be understood as Cryptol types are simply not put into the Cryptol environment.

I don't know offhand of a great way to improve the situation WRT the error message.

@RyanGlScott
Copy link
Contributor Author

Hm, OK. But identity is in a SAW environment of some sort, right? After all, I can do things like:

sawscript> print_term identity;
[16:50:30.629] \(x : Nat) -> x

Would it suffice to check for identifiers that are present in this environment but not present in the Cryptol environment, and if so, give a more specific error message?

@robdockins
Copy link
Contributor

The name resolution at that point is done by the Cryptol renamer; it doesn't know anything about the SAW environment, so it would be hard to do it at the time of lookup. I don't know offhand how a "not in scope" error is propagated, but we could potentially catch it and check if the identifier is in the SAW environment and print a different message.

@atomb
Copy link
Contributor

atomb commented Jul 2, 2021

This would be helped by having Cryptol always return structured error types, rather than textual messages, all the way up to the top level, so the SAWScript REPL could inspect what type of error occurred.

@sauclovian-g sauclovian-g added type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use topics: error-handling Issues involving the way SAW responds to an error condition labels Nov 1, 2024
@sauclovian-g sauclovian-g added this to the 2025T1 milestone Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topics: error-handling Issues involving the way SAW responds to an error condition topics: error-messages Issues involving the messages SAW produces on error type: bug Issues reporting bugs or unexpected/unwanted behavior usability An issue that impedes efficient understanding and use
Projects
None yet
Development

No branches or pull requests

4 participants