Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types for newtype constructors. Fixes #1870 #1871

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 } }};
RyanGlScott marked this conversation as resolved.
Show resolved Hide resolved
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