mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-09-11 14:06:13 +03:00
Make imported signatures work
This commit is contained in:
parent
a56b6ef08e
commit
6bd2ab6bc8
@ -555,7 +555,7 @@ doModParam mp =
|
||||
loc = srcRange sigName
|
||||
withLoc loc
|
||||
do nm <- resolveName NameUse NSSignature (thing sigName)
|
||||
sigEnv <- lookupDefines (ImpNested nm)
|
||||
sigEnv <- lookupSigDefines nm
|
||||
me <- getCurMod
|
||||
let newP x = do y <- lift (newModParam me (mpName mp) loc x)
|
||||
sets_ (Map.insert y x)
|
||||
|
@ -448,7 +448,25 @@ lookupDefines nm =
|
||||
do ro <- RenameM ask
|
||||
case Map.lookup nm (roResolvedModules ro) of
|
||||
Just loc -> pure (rmodDefines loc)
|
||||
Nothing -> maybe mempty modDefines . ($ nm) <$> getLoadedModsMaybe
|
||||
Nothing ->
|
||||
do loaded <- getLoadedMods
|
||||
pure (modDefines (loaded nm))
|
||||
|
||||
lookupSigDefines :: Name -> RenameM NamingEnv
|
||||
lookupSigDefines nm =
|
||||
do ro <- RenameM ask
|
||||
case Map.lookup (ImpNested nm) (roResolvedModules ro) of
|
||||
Just loc -> pure (rmodDefines loc)
|
||||
Nothing ->
|
||||
do getIf <- RenameM (roIfaces <$> ask)
|
||||
let top = nameTopModule nm
|
||||
sigs = ifSignatures (ifPublic (getIf top))
|
||||
case Map.lookup nm sigs of
|
||||
Just s -> pure (modParamsNamingEnv s)
|
||||
Nothing ->
|
||||
panic "lookupSigDefines" [ "Missing signature "<> show nm]
|
||||
|
||||
|
||||
|
||||
|
||||
checkIsModule :: Range -> ImpName Name -> RenameM ()
|
||||
|
11
tests/modsys/functors/T009.cry
Normal file
11
tests/modsys/functors/T009.cry
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
/* Test that importing signatures from another module works */
|
||||
|
||||
import T009_S
|
||||
|
||||
submodule F where
|
||||
import signature A
|
||||
y : [n]
|
||||
y = 1
|
||||
|
||||
|
1
tests/modsys/functors/T009.icry
Normal file
1
tests/modsys/functors/T009.icry
Normal file
@ -0,0 +1 @@
|
||||
:load T009.cry
|
4
tests/modsys/functors/T009.icry.stdout
Normal file
4
tests/modsys/functors/T009.icry.stdout
Normal file
@ -0,0 +1,4 @@
|
||||
Loading module Cryptol
|
||||
Loading module Cryptol
|
||||
Loading module T009_S
|
||||
Loading module Main
|
8
tests/modsys/functors/T009_S.cry
Normal file
8
tests/modsys/functors/T009_S.cry
Normal file
@ -0,0 +1,8 @@
|
||||
module T009_S where
|
||||
|
||||
signature A where
|
||||
type n : #
|
||||
type constraint (fin n, n >= 1)
|
||||
x : [n]
|
||||
|
||||
z = 0x22
|
Loading…
Reference in New Issue
Block a user