Open RyanGlScott opened 7 months ago
It is also possible to make SAW outright panic by using an enum
in the return type of a function:
// Test.cry
f : Option ()
f = None
$ ~/Software/saw-1.1/bin/saw test.saw
[13:33:52.133] Loading file "/home/ryanscott/Documents/Hacking/SAW/test.saw"
[13:33:52.155] You have encountered a bug in cryptol-saw-core's implementation.
*** Please create an issue at https://github.com/GaloisInc/saw-script/issues
%< ---------------------------------------------------
Revision: 5c16c876f35f0abdf0b412a5387e220b15b7f990
Branch: release-1.1 (uncommited files present)
Location: importExpr
Message: unknown variable: Name {nUnique = 4188, nInfo = GlobalName UserName (OrigName {ogNamespace = NSConstructor, ogModule = TopModule (ModName "Cryptol" NormalName), ogSource = FromDefinition, ogName = Ident False NormalName "None", ogFromParam = Nothing}), nFixity = Nothing, nLoc = Range {from = Position {line = 645, col = 17}, to = Position {line = 645, col = 21}, source = "/home/ryanscott/Software/saw-1.1/lib/Cryptol.cry"}}
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:1081:25 in cryptol-saw-core-0.1-inplace:Verifier.SAW.Cryptol
%< ---------------------------------------------------
It's not obvious to me if it is straightforward to fix this panic without doing all of the necessary legwork to support enums wholesale, but I thought I'd mention it here as well.
Since https://github.com/GaloisInc/saw-script/pull/2020, SAW bundles a version of Cryptol that includes support for Cryptol's
enum
declarations. It it still not possible to import Cryptol files that defineenum
s into SAWCore, however. For example, given this Cryptol and SAW file:If you run
test.saw
, it will throw an error message:Alternatively, you might also see this error message if you load a program which uses (but does not define) an
enum
:This issue tracks lifting this restriction. (A further step would be to allow using Cryptol enums in MIR specifications, as proposed in https://github.com/GaloisInc/saw-script/issues/1976.)
In order to import an
enum
into SAWCore, we need to have a corresponding SAWCore representation. Two possible representations that we could pick are:enum
declaration to a SAWCoredata
declaration with the same field types.enum
declaration to a value defined in terms ofEithers
, which provides an "anonymous sum" representation.