-
Notifications
You must be signed in to change notification settings - Fork 323
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
Resolve fully qualified names #4056
Conversation
5c22872
to
c054b8c
Compare
engine/runtime/src/main/scala/org/enso/compiler/pass/resolve/FullyQualifiedNames.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a CompilerBasedDependencyExtractor
that is used to extract dependencies between libraries based on imports.
It is meant to be used to track dependencies between our libs, it is currently not used too heavily, although it is ran as part of generating a manifest for a package.
Since this PR introduces a change which makes libraries loaded not only by imports but also by qualified names, I'd like to ask:
-
If we can make sure that this dependency extractor will also be able to detect which libraries are brought in as part of this pass? If so, it would be good to add a test extracting dependencies of
Test_Fully_Qualified_Name
verifying this works.
1a. Alternatively, maybe we could actually make a pass which desugars the FQN into a regular reference + adding a fake import to the module? What do you think? Maybe then we could avoid modifications in the dependency extractor. It seems quite valuable to have a single place to find dependencies (the list of imports). -
Since this is not necessarily top priority, we may mark this for later, but I think we should create a Pivotal issue to tackle this at some point, to avoid figuring this out in the future by a bug where library dependencies are not tracked correctly.
Wasn't aware of that. Thanks @radeusgd |
engine/runtime/src/main/scala/org/enso/compiler/pass/resolve/FullyQualifiedNames.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have slight preference to smaller change - e.g. without invoking the compiler - if that works when the IDE imports from Standard.Base import all
.
engine/runtime/src/main/scala/org/enso/compiler/context/InlineContext.scala
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/scala/org/enso/compiler/pass/resolve/FullyQualifiedNames.scala
Outdated
Show resolved
Hide resolved
c054b8c
to
7fe6010
Compare
engine/runtime/src/main/scala/org/enso/compiler/pass/resolve/FullyQualifiedNames.scala
Outdated
Show resolved
Hide resolved
Added a separate pass, `FullyQualifiedNames`, that partially resolves fully qualified names. The pass only resolves the library part of the name and replaces it with a reference to the `Main` module. There are 2 scenarios covered in this change: 1) the code uses a fully qualified name to a component that has been parsed/compiled 2) the code uses a fully qualified name to a component that has not be imported For the former case, it is sufficient to just check `PackageRepository` for the presence of the library name. In the latter case we have to ensure that the library has been already parsed and all its imports are resolved. Hence the reference to `Compiler` in the `FullyQualifiedNames` pass.
Don't trigger compilation of library late in the pipeline as this may have undesired consequences for dependency resolutions. This will be a known limitation of FQN.
We are no longer triggering compilation so that is not necessary. Unfortunately, due to the way passes and metadata are currently modeled we cannot pass `PackageRepository` directly to the pass and we have to do it via context.
6bbd6a1
to
60992f2
Compare
Co-authored-by: Radosław Waśko <[email protected]>
Pull Request Description
Added a separate pass,
FullyQualifiedNames
, that partially resolves fully qualified names. The pass only resolves the library part of the name and replaces it with a reference to theMain
module.There are 2 scenarios that could be potentially:
parsed/compiled
imported
For the former case, it is sufficient to just check
PackageRepository
for the presence of the library name.In the latter we have to ensure that the library has been already parsed and all its imports are resolved. That would require the reference to
Compiler
in theFullyQualifiedNames
pass, which could then trigger a full compilation for missing library. Since it has some undesired consequences (tracking of dependencies becomes rather complex) we decided to exclude that scenario until it is really needed.Important Notes
With this change, one can use a fully qualified name directly.
e.g.
Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.