Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ogFromParam to Cryptol URI when importing Cryptol names #1915

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions cryptol-saw-core/src/Verifier/SAW/Cryptol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import qualified Cryptol.Utils.Ident as C
( Ident, PrimIdent(..), mkIdent
, prelPrim, floatPrim, arrayPrim, suiteBPrim, primeECPrim
, ModName, modNameToText, identText, interactiveName
, ModPath(..), modPathSplit, ogModule, Namespace(NSValue)
, ModPath(..), modPathSplit, ogModule, ogFromParam, Namespace(NSValue)
, modNameChunksText
)
import qualified Cryptol.Utils.RecordMap as C
Expand Down Expand Up @@ -1375,10 +1375,18 @@ importName cnm =
let (topMod, nested) = C.modPathSplit (C.ogModule og)
topChunks = C.modNameChunksText topMod
modNms = topChunks ++ map C.identText nested
-- If the name came from a module parameter, add the module
-- parameter identifier to distinguish between names that have the
-- same identifier but come from different module parameters (see
-- #1892)
ifaceNms = case C.ogFromParam og of
Just i -> [C.identText i]
Nothing -> []
RyanGlScott marked this conversation as resolved.
Show resolved Hide resolved
shortNm = C.identText (C.nameIdent cnm)
longNm = Text.intercalate "::" (modNms ++ [shortNm])
nmParts = modNms ++ ifaceNms ++ [shortNm]
longNm = Text.intercalate "::" nmParts
aliases = [shortNm, longNm]
uri = cryptolURI (modNms ++ [shortNm]) Nothing
uri = cryptolURI nmParts Nothing
in pure (ImportedName uri aliases)

-- | Currently this imports declaration groups by inlining all the
Expand Down
3 changes: 3 additions & 0 deletions intTests/test1892/A.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface module A where

a : [8]
6 changes: 6 additions & 0 deletions intTests/test1892/F.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module F where

import interface A as X
import interface A as Y

f = X::a + Y::a
3 changes: 3 additions & 0 deletions intTests/test1892/I.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module I where

a = 1
3 changes: 3 additions & 0 deletions intTests/test1892/J.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module J where

a = 2
1 change: 1 addition & 0 deletions intTests/test1892/M.cry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module M = F { X = I, Y = J }
2 changes: 2 additions & 0 deletions intTests/test1892/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "M.cry";
prove_print z3 {{ f == X::a + Y::a }};
3 changes: 3 additions & 0 deletions intTests/test1892/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -e

$SAW test.saw
Loading