Skip to content

Commit

Permalink
Propagate nested relation when instantiating functors (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy authored Aug 2, 2024
1 parent f489ff8 commit c650eb2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Cryptol/TypeCheck/Module.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ doFunctorInst m f as instMap0 enclosingInScope doc =
mapM_ addNominal (Map.elems (mNominalTypes m2))
addSignatures (mSignatures m2)
addSubmodules (mSubmodules m2)
setNested (mNested m2)
addFunctors (mFunctors m2)
mapM_ addDecls (mDecls m2)

Expand Down
4 changes: 3 additions & 1 deletion src/Cryptol/TypeCheck/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,9 @@ addFunctors :: Map Name (ModuleG Name) -> InferM ()
addFunctors mp =
updScope \r -> r { mFunctors = Map.union mp (mFunctors r) }


setNested :: Set Name -> InferM ()
setNested names =
updScope \r -> r { mNested = names }


-- | The sub-computation is performed with the given abstract function in scope.
Expand Down
23 changes: 23 additions & 0 deletions tests/docstrings/T06.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module T06 where

interface submodule I where
type N : #

submodule N1 where
type N = 1

submodule C where
import interface submodule I

/**
* ```repl
* let x = lost
* ```
*/
lost = ()

submodule B where
import interface submodule I
submodule C_ = submodule C { submodule N1 }

submodule A = submodule B { submodule N1 }
2 changes: 2 additions & 0 deletions tests/docstrings/T06.icry
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:m T06
:check-docstrings
7 changes: 7 additions & 0 deletions tests/docstrings/T06.icry.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Loading module Cryptol
Loading module Cryptol
Loading module T06

let x = lost

Successes: 1, Failures: 0

0 comments on commit c650eb2

Please sign in to comment.