Skip to content

Commit

Permalink
Merge pull request #1767 from GaloisInc/1766-interface-docstrings
Browse files Browse the repository at this point in the history
Allow doc comments on interface modules
  • Loading branch information
sauclovian-g authored Nov 26, 2024
2 parents 56a93da + e032c78 commit 4485d70
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Cryptol/Parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ import Paths_cryptol
top_module :: { [Module PName] }
: mbDoc 'module' module_def {% mkTopMods $1 $3 }
| 'v{' vmod_body 'v}' {% mkAnonymousModule $2 }
| 'interface' 'module' modName 'where' 'v{' sig_body 'v}'
{ mkTopSig $3 $6 }
| mbDoc 'interface' 'module' modName 'where' 'v{' sig_body 'v}'
{ mkTopSig $1 $4 $7 }

module_def :: { Module PName }

Expand Down
6 changes: 3 additions & 3 deletions src/Cryptol/Parser/ParserUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1364,12 +1364,12 @@ mkTopMods doc m =
do (m', ms) <- desugarMod m { mDocTop = doc }
pure (ms ++ [m'])

mkTopSig :: Located ModName -> Signature PName -> [Module PName]
mkTopSig nm sig =
mkTopSig :: Maybe (Located Text) -> Located ModName -> Signature PName -> [Module PName]
mkTopSig doc nm sig =
[ Module { mName = nm
, mDef = InterfaceModule sig
, mInScope = mempty
, mDocTop = Nothing
, mDocTop = doc
}
]

Expand Down
9 changes: 9 additions & 0 deletions tests/docstrings/T12.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** Doc strings on interfaces apply to the interface context.
*
* ```repl
* :check \x y z -> add x (add y z) == add (add x y) z
* ```
*/
interface module I where

add : [8] -> [8] -> [8]
2 changes: 2 additions & 0 deletions tests/docstrings/T12.icry
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:m T12
:check-docstrings
4 changes: 4 additions & 0 deletions tests/docstrings/T12.icry.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Loading module Cryptol
Loading module Cryptol
Loading interface module I
Skipping docstrings on interface module

0 comments on commit 4485d70

Please sign in to comment.