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

Confusing import error #6425

Closed
radeusgd opened this issue Apr 25, 2023 · 3 comments · Fixed by #6808
Closed

Confusing import error #6425

radeusgd opened this issue Apr 25, 2023 · 3 comments · Fixed by #6808
Assignees
Milestone

Comments

@radeusgd
Copy link
Member

Run:

from Standard.Table import Table as My_Table

main = 43

It will print:

In module local.Project_123.Main:
Compiler encountered errors:
Main.enso[1:28-1:44]: Imports must have a valid module path.
Aborting due to 1 errors and 0 warnings.
Execution finished with an error: Compilation aborted due to errors.
        at <java> org.graalvm.sdk/org.graalvm.polyglot.Value.invokeMember(Value.java:971)
        at <java> org.enso.polyglot.Module.getAssociatedType(Module.scala:19)
        at <java> org.enso.runner.Main$.runMain(Main.scala:802)
        at <java> org.enso.runner.Main$.runPackage(Main.scala:725)
        at <java> org.enso.runner.Main$.run(Main.scala:610)
        at <java> org.enso.runner.Main$.main(Main.scala:1111)
        at <java> org.enso.runner.Main.main(Main.scala)

I don't understand what Imports must have a valid module path. means in this context. The path is valid.

The real issue is that I think renaming imports are not supported this way.
Instead to make this work I'd have to write:

import Standard.Table.Data.Table.Table as My_Table

OK, but the error telling me that the first syntax I tried is not supported should ideally be a bit clearer - there is no module path issue.

I think this boils down to the issue that we have:

case object InvalidImport extends Reason {
  override def explanation: String =
    s"Imports must have a valid module path"
}

so this seems to be a constant message for InvalidImport, but apparently there is more than this one way for an import to be invalid - I think we may need more granular error reporting here.

@radeusgd
Copy link
Member Author

Moreover, if I run this in --update-manifest mode, namely:

.\built-distribution\enso-engine-0.0.0-dev-windows-amd64\enso-0.0.0-dev\bin\enso --update-manifest --in-project path\to\project

(where path\to\project is a project whose Main.src has contents as shown above), then I get a compiler crash:

org.graalvm.polyglot.PolyglotException: org.enso.compiler.exception.CompilerError: Compiler Internal Error: Unexpected import type after processing local.Project_123.Main: [IR.Error.Syntax(at = IdentifiedLocation(Location(38,55),None), reason = InvalidImport, location = Some(IdentifiedLocation(Location(38,55),None)), passData = List(), diagnostics = DiagnosticStorage(diagnostics = List()), id = be3d6686-ed7c-479e-87ca-84ca86a63951)].
        at org.enso.compiler.Compiler.$anonfun$gatherImportStatements$1(Compiler.scala:527)
        at scala.collection.immutable.List.flatMap(List.scala:293)
        at org.enso.compiler.Compiler.gatherImportStatements(Compiler.scala:514)
        at org.enso.interpreter.runtime.Module$InvokeMember.gatherImportStatements(Module.java:641)
        at org.enso.interpreter.runtime.Module$InvokeMember.doInvoke(Module.java:670)
        at org.enso.interpreter.runtime.ModuleGen$InteropLibraryExports$Cached.executeAndSpecialize(ModuleGen.java:93)
        at org.enso.interpreter.runtime.ModuleGen$InteropLibraryExports$Cached.invokeMember(ModuleGen.java:80)      
        at org.graalvm.truffle/com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.invokeMember(InteropLibraryGen.java:8328)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$AbstractInvokeNode.executeShared(PolyglotValueDispatch.java:4446)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$InvokeNoArgsNode.executeImpl(PolyglotValueDispatch.java:4510)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)        at org.graalvm.sdk/org.graalvm.polyglot.Value.invokeMember(Value.java:971)
        at org.enso.polyglot.Module.gatherImportStatements(Module.scala:60)
        at org.enso.languageserver.libraries.CompilerBasedDependencyExtractor.findImportedLibraries$1(CompilerBasedDependencyExtractor.scala:29)
        at org.enso.languageserver.libraries.CompilerBasedDependencyExtractor.$anonfun$findDependencies$2(CompilerBasedDependencyExtractor.scala:40)
        at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:118)
        at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:105)
        at scala.collection.immutable.Set$Set1.flatMap(Set.scala:156)
        at org.enso.languageserver.libraries.CompilerBasedDependencyExtractor.findDependencies(CompilerBasedDependencyExtractor.scala:40)
        at org.enso.libraryupload.LibraryUploader.$anonfun$updateManifest$1(LibraryUploader.scala:95)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at scala.util.Try$.apply(Try.scala:210)
        at org.enso.libraryupload.LibraryUploader.updateManifest(LibraryUploader.scala:94)
        at org.enso.runner.ProjectUploader$.updateManifest(ProjectUploader.scala:76)
        at org.enso.runner.Main$.main(Main.scala:1076)
        at org.enso.runner.Main.main(Main.scala)
Original Internal Error:
org.enso.compiler.exception.CompilerError: Compiler Internal Error: Unexpected import type after processing local.Project_123.Main: [IR.Error.Syntax(at = IdentifiedLocation(Location(38,55),None), reason = InvalidImport, location = Some(IdentifiedLocation(Location(38,55),None)), passData = List(), diagnostics = DiagnosticStorage(diagnostics = List()), id = be3d6686-ed7c-479e-87ca-84ca86a63951)].
        at org.enso.compiler.Compiler.$anonfun$gatherImportStatements$1(Compiler.scala:527)
        at scala.collection.immutable.List.flatMap(List.scala:293)
        at org.enso.compiler.Compiler.gatherImportStatements(Compiler.scala:514)
        at org.enso.interpreter.runtime.Module$InvokeMember.gatherImportStatements(Module.java:641)
        at org.enso.interpreter.runtime.Module$InvokeMember.doInvoke(Module.java:670)
        at org.enso.interpreter.runtime.ModuleGen$InteropLibraryExports$Cached.executeAndSpecialize(ModuleGen.java:93)
        at org.enso.interpreter.runtime.ModuleGen$InteropLibraryExports$Cached.invokeMember(ModuleGen.java:80)      
        at org.graalvm.truffle/com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.invokeMember(InteropLibraryGen.java:8328)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$AbstractInvokeNode.executeShared(PolyglotValueDispatch.java:4446)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$InvokeNoArgsNode.executeImpl(PolyglotValueDispatch.java:4510)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:709)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:632)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:565)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:549)
        at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.GraalRuntimeSupport.callProfiled(GraalRuntimeSupport.java:256)
        at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue.invoke(PolyglotValueDispatch.java:2426)
        at org.graalvm.sdk/org.graalvm.polyglot.Value.invokeMember(Value.java:971)
        at org.enso.polyglot.Module.gatherImportStatements(Module.scala:60)
        at org.enso.languageserver.libraries.CompilerBasedDependencyExtractor.findImportedLibraries$1(CompilerBasedDependencyExtractor.scala:29)
        at org.enso.languageserver.libraries.CompilerBasedDependencyExtractor.$anonfun$findDependencies$2(CompilerBasedDependencyExtractor.scala:40)
        at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:118)
        at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:105)
        at scala.collection.immutable.Set$Set1.flatMap(Set.scala:156)
        at org.enso.languageserver.libraries.CompilerBasedDependencyExtractor.findDependencies(CompilerBasedDependencyExtractor.scala:40)
        at org.enso.libraryupload.LibraryUploader.$anonfun$updateManifest$1(LibraryUploader.scala:95)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at scala.util.Try$.apply(Try.scala:210)
        at org.enso.libraryupload.LibraryUploader.updateManifest(LibraryUploader.scala:94)
        at org.enso.runner.ProjectUploader$.updateManifest(ProjectUploader.scala:76)
        at org.enso.runner.Main$.main(Main.scala:1076)
        at org.enso.runner.Main.main(Main.scala)
Caused by: Attached Guest Language Frames (1)

@hubertp hubertp self-assigned this Apr 26, 2023
@hubertp hubertp removed the triage label Apr 26, 2023
@jdunkerley jdunkerley modified the milestone: Design Partners May 2, 2023
@jdunkerley jdunkerley moved this from ❓New to 📤 Backlog in Issues Board May 2, 2023
@jdunkerley jdunkerley added this to the Beta Release milestone May 2, 2023
@jdunkerley jdunkerley moved this from 📤 Backlog to ❓New in Issues Board May 2, 2023
@jdunkerley jdunkerley assigned Akirathan and unassigned hubertp May 2, 2023
@jdunkerley jdunkerley moved this from ❓New to 📤 Backlog in Issues Board May 2, 2023
@Akirathan Akirathan moved this from 📤 Backlog to ⚙️ Design in Issues Board May 22, 2023
@Akirathan Akirathan moved this from ⚙️ Design to 🔧 Implementation in Issues Board May 22, 2023
@enso-bot
Copy link

enso-bot bot commented May 22, 2023

Pavel Marek reports a new STANDUP for today (2023-05-22):

Progress: - Looking into where the error message stems from

  • Looking into how one can change TreeToIr.java to get a more informative error message from the import
    • I might add a special handling for these cases. It should be finished by 2023-05-25.

@Akirathan Akirathan linked a pull request May 23, 2023 that will close this issue
5 tasks
@github-project-automation github-project-automation bot moved this from 🔧 Implementation to 🟢 Accepted in Issues Board May 23, 2023
@enso-bot
Copy link

enso-bot bot commented May 24, 2023

Pavel Marek reports a new STANDUP for yesterday (2023-05-23):

Progress: - More improvements It should be finished by 2023-05-25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants