[ fix #1970 ] error on mod self ref (#1977)

This commit is contained in:
Alissa Tung 2021-10-08 17:09:17 +08:00 committed by GitHub
parent d4263441b7
commit e15c78ce9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 6 deletions

View File

@ -85,6 +85,9 @@ mkModTree loc done modFP mod
do file <- maybe (nsToSource loc mod) pure modFP
modInfo <- readHeader file mod
let imps = map path (imports modInfo)
if mod `elem` imps
then coreFail $ CyclicImports [mod, mod]
else do
ms <- traverse (mkModTree loc (mod :: done) Nothing) imps
let mt = MkModTree mod (Just file) ms
all <- get AllMods

View File

@ -194,7 +194,7 @@ idrisTests = MkTestPool "Misc" [] Nothing
-- Eta equality
"eta001",
-- Modules and imports
"import001", "import002", "import003", "import004", "import005",
"import001", "import002", "import003", "import004", "import005", "import006",
-- Implicit laziness, lazy evaluation
"lazy001", "lazy002",
-- Namespace blocks

View File

@ -0,0 +1,3 @@
module A.B
import A.B

View File

@ -0,0 +1,3 @@
module A.C
import A.B

View File

@ -0,0 +1,3 @@
package cyclic
modules = A.B, A.C

View File

@ -0,0 +1 @@
Uncaught error: Module imports form a cycle: A.B -> A.B

View File

@ -0,0 +1,3 @@
rm -rf build
$1 --no-color --console-width 0 --no-banner --build cyclic.ipkg