Skip to content

Commit

Permalink
saw-core-sbv: Handle zero-width bitvectors properly in counterexamples.
Browse files Browse the repository at this point in the history
Fixes #1182.
  • Loading branch information
Brian Huffman committed May 5, 2021
1 parent e9b20e6 commit 2906402
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion saw-core-sbv/src/Verifier/SAW/Simulator/SBV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ data Labeler
= BoolLabel String
| IntegerLabel String
| WordLabel String
| ZeroWidthWordLabel
| VecLabel (Vector Labeler)
| TupleLabel (Vector Labeler)
| RecLabel (Map FieldName Labeler)
Expand All @@ -684,7 +685,7 @@ newVars FOTInt = nextId <&> \s-> (IntegerLabel s, vInteger <$> existsSInteger s)
newVars (FOTIntMod n) = nextId <&> \s-> (IntegerLabel s, VIntMod n <$> existsSInteger s)
newVars (FOTVec n FOTBit) =
if n == 0
then nextId <&> \s-> (WordLabel s, return (vWord (literalSWord 0 0)))
then pure (ZeroWidthWordLabel, pure (vWord (literalSWord 0 0)))
else nextId <&> \s-> (WordLabel s, vWord <$> existsSWord s (fromIntegral n))
newVars (FOTVec n tp) = do
(labels, vals) <- V.unzip <$> V.replicateM (fromIntegral n) (newVars tp)
Expand Down Expand Up @@ -718,6 +719,8 @@ getLabels ls d args
getLabel (WordLabel s) = FOVWord (cvKind cv) (cvToInteger cv)
where cv = d Map.! s

getLabel ZeroWidthWordLabel = FOVWord 0 0

getLabel (VecLabel ns)
| V.null ns = error "getLabel of empty vector"
| otherwise = fovVec t vs
Expand Down

0 comments on commit 2906402

Please sign in to comment.