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

Infer correct synthetic name for nested modules #6525

Merged
merged 1 commit into from
May 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,12 @@ object PackageRepository {
s"""|import $modName
|export $modName
|""".stripMargin
(
QualifiedName(namespace :: name :: parts, lastModuleName),
val syntheticModuleInfo = (
QualifiedName(namespace :: name :: parts.reverse, lastModuleName),
QualifiedName(namespace :: name :: pathElems, exportItem),
modSource
) :: listAllIntermediateModules(
)
syntheticModuleInfo :: listAllIntermediateModules(
namespace,
name,
parts,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Test_Deeply_Nested_Modules
license: APLv2
enso-version: default
version: "0.0.1"
author: "Enso Team <[email protected]>"
maintainer: "Enso Team <[email protected]>"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Foo_A
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type A_Mod
Value a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Foo_B
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type B_Mod
Value a
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type C_Mod
Value a
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type D_Mod
Value a
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from Standard.Base import all

import project.A.A_Mod
import project.A.B.B_Mod
import project.A.B

main =
IO.println (A_Mod.A_Mod.Value 1)
IO.println (B.C.C_Mod.C_Mod.Value 1)
IO.println (B.C.D.D_Mod.D_Mod.Value 1)
0
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,15 @@ class ImportsTest extends PackageTest {
) shouldEqual "Main.enso[2:1-2:57]: The exported type `Atom` in `local.Test_Fully_Qualified_Name_Conflict.Atom` module will cause name conflict when attempting to use a fully qualified name of the `local.Test_Fully_Qualified_Name_Conflict.Atom.Foo` module."
}

"Deeply nested modules" should "infer correct synthetic modules" in {
evalTestProject(
"Test_Deeply_Nested_Modules"
).toString shouldEqual "0"
val outLines = consumeOut
outLines should have length 3
outLines(0) shouldEqual "(A_Mod.Value 1)"
outLines(1) shouldEqual "(C_Mod.Value 1)"
outLines(2) shouldEqual "(D_Mod.Value 1)"
}

}