Skip to content

Commit

Permalink
Add nominal type constructors in scope.
Browse files Browse the repository at this point in the history
Fixes #1617
  • Loading branch information
yav committed Jan 31, 2024
1 parent c06fc89 commit e5251ee
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Cryptol/TypeCheck/Sanity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ tcModule env m = case runTcM env check of
where check = foldr withTVar k1 (map mtpParam (Map.elems (mParamTypes m)))
k1 = foldr withAsmp k2 (map thing (mParamConstraints m))
k2 = withVars (Map.toList (fmap mvpType (mParamFuns m)))
$ withVars (concatMap nominalTypeConTypes
(Map.elems (mNominalTypes m)))
$ checkDecls (mDecls m)

onlyNonTrivial :: [ProofObligation] -> [ProofObligation]
Expand Down Expand Up @@ -575,9 +577,16 @@ runTcM env (TcM m) =
, let x = mtpParam tp ]
, roAsmps = map thing (mpnConstraints allPs)
, roRange = emptyRange
, roVars = Map.union
(fmap mvpType (mpnFuns allPs))
(inpVars env)
, roVars = Map.unions
[ fmap mvpType (mpnFuns allPs)
, inpVars env
, Map.fromList
[ c
| nt <- Map.elems (inpNominalTypes env)
, c <- nominalTypeConTypes nt
]
]

}
rw = RW { woProofObligations = [] }

Expand Down
8 changes: 8 additions & 0 deletions tests/issues/issue1617.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Bar.cry
newtype T = { unT : [8] }
enum M = A | B

f : T
f = T { unT = 0 }

g = A
2 changes: 2 additions & 0 deletions tests/issues/issue1617.icry
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:set coreLint=true
:load issue1617.cry
8 changes: 8 additions & 0 deletions tests/issues/issue1617.icry.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Loading module Cryptol
Loading module Cryptol
{n, a, b, c} n == min n n
{a, n} (fin n) => inf == inf * (1 * (1 * 1))
{a, n} (fin n) => n / 2 == n - n /^ 2
{n, a, b} n == min n n
{n} (n >= 1, fin n) => (fin n, n >= 1)
Loading module Main

0 comments on commit e5251ee

Please sign in to comment.