Skip to content

Commit

Permalink
Merge pull request #1915 from GaloisInc/T1892
Browse files Browse the repository at this point in the history
Add `ogFromParam` to Cryptol URI when importing Cryptol names
  • Loading branch information
mergify[bot] authored Aug 24, 2023
2 parents 4758d2d + fd8a525 commit 128e8f8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 3 deletions.
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 -> []
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

0 comments on commit 128e8f8

Please sign in to comment.