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

Inconsistent import X.Y.Z and from X.Y import Z #10399

Open
Akirathan opened this issue Jun 28, 2024 · 0 comments
Open

Inconsistent import X.Y.Z and from X.Y import Z #10399

Akirathan opened this issue Jun 28, 2024 · 0 comments
Assignees
Labels
--bug Type: bug -compiler -syntax p-medium Should be completed in the next few sprints

Comments

@Akirathan
Copy link
Member

Akirathan commented Jun 28, 2024

The two types of imports from project.Module import Something and import project.Module.Something should be semantically exactly the same. But they are not. For example, changing the line in the test in

|import $namespace.$packageName.My_Module.My_Type.Constructor
to

diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala
index 7ac98a8890..5335ddfc75 100644
--- a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala
+++ b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala
@@ -288,7 +288,7 @@ class ImportExportTest
 
       val mainIr =
         s"""
-          |import $namespace.$packageName.My_Module.My_Type.Constructor
+          |from $namespace.$packageName.My_Module.My_Type import Constructor
           |""".stripMargin
           .createModule(packageQualifiedName.createChild("Main"))
           .getIr

will make the test fail.

The same is true for exports.

The reason for that is because ImportResolverAlgorithm.tryResolveImport does not consider the symbols in the from ... import <symbols> case at all. The algorithm should be improved to handle all the symbols from these kinds of imports as well. For that, we will most likely have to change the definition of the Result type parameter.

@Akirathan Akirathan added p-medium Should be completed in the next few sprints --bug Type: bug -compiler -syntax labels Jun 28, 2024
@Akirathan Akirathan self-assigned this Jun 28, 2024
@JaroslavTulach JaroslavTulach changed the title Inconsistent imports Inconsistent import X.Y.Z and from X.Y import Z Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--bug Type: bug -compiler -syntax p-medium Should be completed in the next few sprints
Projects
Status: New
Development

No branches or pull requests

1 participant