mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-12-25 17:04:31 +03:00
Rename type synonyms properly.
This commit is contained in:
parent
3443331f06
commit
2272a59314
@ -43,9 +43,13 @@ instantiateModule func newName tpMap vpMap =
|
||||
|
||||
env <- computeEnv func tpMap vpNames
|
||||
|
||||
let renamedExports = inst env (mExports func)
|
||||
renamedTySyns = fmap (inst env) (mTySyns func)
|
||||
renamedNewtypes = fmap (inst env) (mNewtypes func)
|
||||
let rnMp :: Inst a => (a -> Name) -> Map Name a -> Map Name a
|
||||
rnMp f m = Map.fromList [ (f x, x) | a <- Map.elems m
|
||||
, let x = inst env a ]
|
||||
|
||||
renamedExports = inst env (mExports func)
|
||||
renamedTySyns = rnMp tsName (mTySyns func)
|
||||
renamedNewtypes = rnMp ntName (mNewtypes func)
|
||||
|
||||
su = listSubst
|
||||
[ (TVBound tp, t) | (tp,t) <- Map.toList (tyParamMap env) ]
|
||||
@ -256,7 +260,7 @@ instance Inst (ExportSpec Name) where
|
||||
instV x = Map.findWithDefault x x (funNameMap env)
|
||||
|
||||
instance Inst TySyn where
|
||||
inst env ts = TySyn { tsName = Map.findWithDefault x x (tyNameMap env)
|
||||
inst env ts = TySyn { tsName = instTyName env x
|
||||
, tsParams = tsParams ts
|
||||
, tsConstraints = inst env (tsConstraints ts)
|
||||
, tsDef = inst env (tsDef ts)
|
||||
@ -265,7 +269,7 @@ instance Inst TySyn where
|
||||
where x = tsName ts
|
||||
|
||||
instance Inst Newtype where
|
||||
inst env nt = Newtype { ntName = Map.findWithDefault x x (tyNameMap env)
|
||||
inst env nt = Newtype { ntName = instTyName env x
|
||||
, ntParams = ntParams nt
|
||||
, ntConstraints = inst env (ntConstraints nt)
|
||||
, ntFields = [ (f,inst env t) | (f,t) <- ntFields nt ]
|
||||
@ -273,7 +277,8 @@ instance Inst Newtype where
|
||||
}
|
||||
where x = ntName nt
|
||||
|
||||
|
||||
instTyName :: Env -> Name -> Name
|
||||
instTyName env x = Map.findWithDefault x x (tyNameMap env)
|
||||
|
||||
|
||||
|
||||
|
1
tests/modsys/T13.icry
Normal file
1
tests/modsys/T13.icry
Normal file
@ -0,0 +1 @@
|
||||
:module T13::Main
|
4
tests/modsys/T13.icry.stdout
Normal file
4
tests/modsys/T13.icry.stdout
Normal file
@ -0,0 +1,4 @@
|
||||
Loading module Cryptol
|
||||
Loading module T13::A
|
||||
Loading module T13::B
|
||||
Loading module T13::Main
|
11
tests/modsys/T13/A.cry
Normal file
11
tests/modsys/T13/A.cry
Normal file
@ -0,0 +1,11 @@
|
||||
module T13::A where
|
||||
|
||||
parameter
|
||||
type T : #
|
||||
type constraint (2 >= T)
|
||||
f : [8] -> [8]
|
||||
|
||||
type X = T + 1
|
||||
g = f
|
||||
|
||||
|
13
tests/modsys/T13/B.cry
Normal file
13
tests/modsys/T13/B.cry
Normal file
@ -0,0 +1,13 @@
|
||||
module T13::B = T13::A where
|
||||
|
||||
/*
|
||||
parameter
|
||||
type T : #
|
||||
type constraint (2 >= T)
|
||||
*/
|
||||
|
||||
type T = 1
|
||||
|
||||
f x = x
|
||||
|
||||
|
6
tests/modsys/T13/Main.cry
Normal file
6
tests/modsys/T13/Main.cry
Normal file
@ -0,0 +1,6 @@
|
||||
module T13::Main where
|
||||
|
||||
import T13::B
|
||||
|
||||
h : [X]
|
||||
h = zero
|
Loading…
Reference in New Issue
Block a user