Skip to content

Commit

Permalink
Avoid calling wordLit with bitsizes greater than maxBitIntWidth.
Browse files Browse the repository at this point in the history
Fixes #636.
  • Loading branch information
Brian Huffman committed Jul 24, 2019
1 parent 2e72a73 commit 12805be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Cryptol/Eval/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,10 @@ instance BitWord Bool BV Integer where

-- | Create a packed word of n bits.
word :: BitWord b w i => Integer -> Integer -> GenValue b w i
word n i = VWord n $ ready $ WordVal $ wordLit n i
word n i
| n >= Arch.maxBigIntWidth = wordTooWide n
| otherwise = VWord n $ ready $ WordVal $ wordLit n i


lam :: (Eval (GenValue b w i) -> Eval (GenValue b w i)) -> GenValue b w i
lam = VFun
Expand Down
5 changes: 1 addition & 4 deletions src/Cryptol/Prims/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Control.Monad (join, unless)

import Cryptol.TypeCheck.AST
import Cryptol.TypeCheck.Solver.InfNat (Nat'(..),fromNat,genLog, nMul)
import qualified Cryptol.Eval.Arch as Arch
import Cryptol.Eval.Monad
import Cryptol.Eval.Type
import Cryptol.Eval.Value
Expand Down Expand Up @@ -220,9 +219,7 @@ mkLit ty =
case ty of
TVInteger -> VInteger . integerLit
TVIntMod _ -> VInteger . integerLit
TVSeq w TVBit
| w >= Arch.maxBigIntWidth -> wordTooWide w
| otherwise -> word w
TVSeq w TVBit -> word w
_ -> evalPanic "Cryptol.Eval.Prim.evalConst"
[ "Invalid type for number" ]

Expand Down

0 comments on commit 12805be

Please sign in to comment.