Skip to content

Commit

Permalink
Throw exception when symbolically evaluating enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed Jan 23, 2024
1 parent f0706f9 commit 0a3a2e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/Cryptol/Symbolic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Cryptol.Symbolic
, ProverResult(..)
, ProverStats
, CounterExampleType(..)
, SymbolicException(..)
-- * FinType
, FinType(..)
, FinNewtype(..)
Expand All @@ -44,6 +45,7 @@ module Cryptol.Symbolic
) where


import qualified Control.Exception as X
import Control.Monad (foldM)
import Data.Map(Map)
import Data.IORef(IORef)
Expand Down Expand Up @@ -120,7 +122,13 @@ data ProverResult = AllSatResult [SatResult] -- LAZY
| EmptyResult
| ProverError String

data SymbolicException = UnsupportedEnums

instance Show SymbolicException where
showsPrec _ UnsupportedEnums =
showString "Enums are not currently supported with symbolic evaluation."

instance X.Exception SymbolicException

predArgTypes :: QueryType -> Schema -> Either String [FinType]
predArgTypes qtype schema@(Forall ts ps ty)
Expand Down Expand Up @@ -294,7 +302,7 @@ freshVar fns tp =
FTNewtype _ _ nv ->
case nv of
FStruct fs -> VarRecord <$> traverse (freshVar fns) fs
-- XXX: FEnum
FEnum{} -> X.throw UnsupportedEnums

computeModel ::
PrimMap ->
Expand Down
6 changes: 4 additions & 2 deletions src/Cryptol/Symbolic/SBV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,10 @@ parseValue (FTRecord r) cvs = (VarRecord r', cvs')
fs = zip ns vs
r' = recordFromFieldsWithDisplay (displayOrder r) fs

parseValue (FTNewtype _ _ (FStruct r)) cvs = parseValue (FTRecord r) cvs
--- XXX: Enum
parseValue (FTNewtype _ _ nv) cvs =
case nv of
FStruct r -> parseValue (FTRecord r) cvs
FEnum{} -> X.throw UnsupportedEnums

parseValue (FTFloat e p) cvs =
(VarFloat FH.BF { FH.bfValue = bfNaN
Expand Down

0 comments on commit 0a3a2e1

Please sign in to comment.