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

feat(libflux): associate registry attributes to import statements #5332

Merged
merged 1 commit into from
Nov 9, 2022

Conversation

jsternberg
Copy link
Contributor

This change retrieves the @registry attribute from the package and
associates those definitions with corresponding imports in the same
package.

This gets encoded in the semantic graph and the flatbuffer so it is
accessible in both Rust and Go.

Fixes #5311.

Checklist

Dear Author 👋, the following checks should be completed (or explicitly dismissed) before merging.

  • ✏️ Write a PR description, regardless of triviality, to include the value of this PR
  • 🔗 Reference related issues
  • 🏃 Test cases are included to exercise the new code
  • 🧪 If new packages are being introduced to stdlib, link to Working Group discussion notes and ensure it lands under experimental/
  • 📖 If language features are changing, ensure docs/Spec.md has been updated

Dear Reviewer(s) 👋, you are responsible (among others) for ensuring the completeness and quality of the above before approval.

@jsternberg jsternberg requested a review from a team as a code owner November 7, 2022 19:47
@jsternberg jsternberg requested review from Marwes and removed request for a team November 7, 2022 19:47
@jsternberg jsternberg force-pushed the feat/module-imports branch 3 times, most recently from e6bd4c6 to e36fe10 Compare November 7, 2022 20:50
if p.is_empty() || p == "." || p == ".." {
self.errors.push(located(
path.base.location.clone(),
ErrorKind::InvalidImportPath(path_str.to_string()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could explain why the path is invalid more precisely, either by pointing precisely to the invalid segment, or explaining why a segment is invalid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give this a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I changed the error message to be specific about which path segment. I couldn't really get it to point to the exact location, but it should have the location of the import itself and the path segment that was invalid.

@@ -610,7 +610,8 @@ pub struct ImportDeclaration {
pub loc: ast::SourceLocation,

pub alias: Option<Identifier>,
pub path: StringLit,
pub registry: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This could maybe be an enum to make it clearer

enum Registry {
    Stdlib,
    Other(String),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change, but just wanted to note that this isn't going to end up influencing the flatbuffers representation. I think it adds clarity to the Rust code but it doesn't really add anything to flatbuffers in my opinion and the flatbuffers representation will likely be removed if we refactor the execution to happen in Rust anyway so I don't want to spend too much time on adding an enum to flatbuffers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to integrate this and I think I'll just merge the current version and we can reconsider this in the future.

The reason is because I started to make the change and thought, "Well the standard library isn't really a registry. So let me use a different name." Then I started going down a rabbit hole of changing names and I'd like to get this merged to unblock other work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think this needs to be represented in the flatbuffer, just would be nice to be clearer on the rust side.

As *Identifier
Path *StringLiteral
As *Identifier
Registry *string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: When resolving the import here on the go side you could add an error case for when a registry exist, to serve as a point to fill in the actual implementation later if nothing else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to follow as the next PR for the Go side.

@jsternberg jsternberg force-pushed the feat/module-imports branch 2 times, most recently from 7f82391 to 886f414 Compare November 8, 2022 15:56
@jsternberg jsternberg force-pushed the feat/module-imports branch 2 times, most recently from 54df263 to 51734b8 Compare November 9, 2022 15:48
This change retrieves the `@registry` attribute from the package and
associates those definitions with corresponding imports in the same
package.

This gets encoded in the semantic graph and the flatbuffer so it is
accessible in both Rust and Go.
@jsternberg jsternberg merged commit 77b1d78 into master Nov 9, 2022
@jsternberg jsternberg deleted the feat/module-imports branch November 9, 2022 16:37
nathanielc added a commit that referenced this pull request Nov 14, 2022
nathanielc added a commit that referenced this pull request Nov 14, 2022
…lsa query (#5324)" (#5342)

* fix: revert "feat: Download Flux modules within runtime as part of Salsa query (#5324)"

This reverts commit cced93e.
The commit broke nightlies.

* fix: revert "feat(libflux): associate registry attributes to import statements (#5332)"

This reverts commit 77b1d78.

* fix: revert "refactor: Remove flux_analyze (#5335)"

This reverts commit 1db3400.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Design and Implement Import Namespacing
2 participants