Skip to content

Commit

Permalink
Merge pull request #1871 from GaloisInc/fix_1870
Browse files Browse the repository at this point in the history
Add types for `newtype` constructors.  Fixes #1870
  • Loading branch information
yav authored May 23, 2023
2 parents 29363db + 831e35d commit b89b8df
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cryptol-saw-core/src/Verifier/SAW/CryptolEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,12 @@ mkCryEnv env =
(types, _) <-
liftModuleM modEnv $
do prims <- MB.getPrimMap
-- noIfaceParams because we don't support translating functors yet
TM.inpVars `fmap` MB.genInferInput P.emptyRange prims
MI.noIfaceParams ifaceDecls
infInp <- MB.genInferInput P.emptyRange prims MI.noIfaceParams ifaceDecls
let newtypeCons = Map.fromList
[ (T.ntName nt, T.newtypeConType nt)
| nt <- Map.elems (TM.inpNewtypes infInp)
]
pure (newtypeCons `Map.union` TM.inpVars infInp)
let types' = Map.union (eExtraTypes env) types
let terms = eTermEnv env
let cryEnv = C.emptyEnv
Expand Down
4 changes: 4 additions & 0 deletions intTests/test_1870/A.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module A where

newtype A = { x : [8] }

5 changes: 5 additions & 0 deletions intTests/test_1870/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "A.cry";

// Make sure that `newtypes` work.
// Specifically, that `A` is in scope.
print {{ A { x = 2 } }};
2 changes: 2 additions & 0 deletions intTests/test_1870/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set -e
$SAW test.saw

0 comments on commit b89b8df

Please sign in to comment.