Skip to content

Commit b89b8df

Browse files
authored
Merge pull request #1871 from GaloisInc/fix_1870
Add types for `newtype` constructors. Fixes #1870
2 parents 29363db + 831e35d commit b89b8df

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

cryptol-saw-core/src/Verifier/SAW/CryptolEnv.hs

+6-3
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,12 @@ mkCryEnv env =
297297
(types, _) <-
298298
liftModuleM modEnv $
299299
do prims <- MB.getPrimMap
300-
-- noIfaceParams because we don't support translating functors yet
301-
TM.inpVars `fmap` MB.genInferInput P.emptyRange prims
302-
MI.noIfaceParams ifaceDecls
300+
infInp <- MB.genInferInput P.emptyRange prims MI.noIfaceParams ifaceDecls
301+
let newtypeCons = Map.fromList
302+
[ (T.ntName nt, T.newtypeConType nt)
303+
| nt <- Map.elems (TM.inpNewtypes infInp)
304+
]
305+
pure (newtypeCons `Map.union` TM.inpVars infInp)
303306
let types' = Map.union (eExtraTypes env) types
304307
let terms = eTermEnv env
305308
let cryEnv = C.emptyEnv

intTests/test_1870/A.cry

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module A where
2+
3+
newtype A = { x : [8] }
4+

intTests/test_1870/test.saw

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import "A.cry";
2+
3+
// Make sure that `newtypes` work.
4+
// Specifically, that `A` is in scope.
5+
print {{ A { x = 2 } }};

intTests/test_1870/test.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set -e
2+
$SAW test.saw

0 commit comments

Comments
 (0)