mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-11-13 23:41:38 +03:00
Don't crash on undefined names.
When we resolve an undfined name we record error, but we continue processing things, so that we can report multiple errors. As a result we need to generate some sort of fake "real" name for the undefined entity. Previously we used to generate a fake local name, but that confused parts of the code that expected certain things to always be defined at the top level. So now we generate a fake name in the Cryptol prelude instead.
This commit is contained in:
parent
6ab14706af
commit
1e3ad37127
@ -52,7 +52,7 @@ import Cryptol.Parser.AST
|
||||
import Cryptol.Parser.Selector(selName)
|
||||
import Cryptol.Utils.Panic (panic)
|
||||
import Cryptol.Utils.RecordMap
|
||||
import Cryptol.Utils.Ident(allNamespaces,OrigName(..),modPathCommon)
|
||||
import Cryptol.Utils.Ident(allNamespaces,OrigName(..),modPathCommon,preludeName)
|
||||
import Cryptol.Utils.PP
|
||||
|
||||
import Cryptol.ModuleSystem.Interface
|
||||
@ -643,6 +643,7 @@ instance Rename TopDecl where
|
||||
renI :: Located (ImportG (ImpName PName)) ->
|
||||
RenameM (Located (ImportG (ImpName Name)))
|
||||
renI li =
|
||||
withLoc (srcRange li)
|
||||
do m <- rename (iModule i)
|
||||
recordImport (srcRange li) m
|
||||
pure li { thing = i { iModule = m } }
|
||||
@ -838,7 +839,8 @@ renameType nt = resolveName nt NSType
|
||||
mkFakeName :: Namespace -> PName -> RenameM Name
|
||||
mkFakeName ns pn =
|
||||
do ro <- RenameM ask
|
||||
liftSupply (mkLocal ns (getIdent pn) (roLoc ro))
|
||||
liftSupply (mkDeclared ns (TopModule preludeName) SystemName (getIdent pn)
|
||||
Nothing (roLoc ro))
|
||||
|
||||
-- | Rename a schema, assuming that none of its type variables are already in
|
||||
-- scope.
|
||||
|
2
tests/modsys/nested/T16.cry
Normal file
2
tests/modsys/nested/T16.cry
Normal file
@ -0,0 +1,2 @@
|
||||
import T16_M
|
||||
import submodule A
|
1
tests/modsys/nested/T16.icry
Normal file
1
tests/modsys/nested/T16.icry
Normal file
@ -0,0 +1 @@
|
||||
:load T16.cry
|
7
tests/modsys/nested/T16.icry.stdout
Normal file
7
tests/modsys/nested/T16.icry.stdout
Normal file
@ -0,0 +1,7 @@
|
||||
Loading module Cryptol
|
||||
Loading module Cryptol
|
||||
Loading module T16_M
|
||||
Loading module Main
|
||||
|
||||
[error] at T16.cry:2:1--2:19
|
||||
Module not in scope: A
|
4
tests/modsys/nested/T16_M.cry
Normal file
4
tests/modsys/nested/T16_M.cry
Normal file
@ -0,0 +1,4 @@
|
||||
module T16_M where
|
||||
private
|
||||
submodule A where
|
||||
x = 0x02
|
Loading…
Reference in New Issue
Block a user