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

Allow importing definitions from parent module using super. #4835

Closed
TomAFrench opened this issue Apr 18, 2024 · 1 comment · Fixed by #5502
Closed

Allow importing definitions from parent module using super. #4835

TomAFrench opened this issue Apr 18, 2024 · 1 comment · Fixed by #5502
Assignees

Comments

@TomAFrench
Copy link
Member

Rust has the concept of super which allows importing from the parent module. Noir doesn't have this so all imports from non-descendant modules within the same crate must specify a full crate:: import.

This is especially useful for when writing tests and grouping them within a submodule

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Apr 18, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 18, 2024
# Description

## Problem\*

## Summary\*

This PR reserves the keyword `super` in prep for #4835 

## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@LogvinovLeon
Copy link
Contributor

This would be awesome. Also - being able to do super::* in tests would be a big help

github-merge-queue bot pushed a commit that referenced this issue Jul 15, 2024
# Description

## Problem

Resolves #4835

## Summary

Implements `super` in `use` statements and regular paths. For example:

```rust
fn some_function() {}

mod foo {
  use super::some_function(); // used in a `use`

  fn another_function() {
    super::some_function(); // used in a path
  }

  fn foo() {
    some_function(); // of course this also works because of the `use` above
  }
}
```

Note that, unlike Rust, only one `super` is allowed: `super::super::...`
will give an error.

## Additional Context

None.

## Documentation\*

Check one:
- [ ] No documentation needed.
- [x] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants