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

Re-exports don't work #3889

Closed
sirasistant opened this issue Dec 20, 2023 · 1 comment · Fixed by #3903
Closed

Re-exports don't work #3889

sirasistant opened this issue Dec 20, 2023 · 1 comment · Fixed by #3903
Assignees
Labels
bug Something isn't working

Comments

@sirasistant
Copy link
Contributor

Aim

Compiling a structure like this one

mod Foo {
    struct NewType{
        a: Field,
    }
}

mod Bar {
    use crate::Foo::NewType as BarStruct;
    use crate::Foo::NewType;
}

mod Baz {
    struct Works {
        a: Field,
    }
    use crate::Bar::BarStruct;
    use crate::Bar::NewType;
}

fn main(works: Baz::Works, fails: Baz::BarStruct, also_fails: Baz::NewType) -> pub Field {
    works.a + fails.a + also_fails.a
}

Expected Behavior

Should compile

Bug

% nargo compile                                                                                                                                                                                ~/constructor mainframe
error: Could not resolve 'BarStruct' in path
   ┌─ /mnt/user-data/alvaro/constructor/src/main.nr:23:21
   │
23 │     use crate::Bar::BarStruct;
   │                     ---------
   │

error: Could not resolve 'NewType' in path
   ┌─ /mnt/user-data/alvaro/constructor/src/main.nr:24:21
   │
24 │     use crate::Bar::NewType;
   │                     -------
   │

error: Could not resolve 'BarStruct' in path
   ┌─ /mnt/user-data/alvaro/constructor/src/main.nr:27:40
   │
27 │ fn main(works: Baz::Works, fails: Baz::BarStruct, also_fails: Baz::NewType) -> pub Field {
   │                                        ---------
   │

error: Could not resolve 'NewType' in path
   ┌─ /mnt/user-data/alvaro/constructor/src/main.nr:27:68
   │
27 │ fn main(works: Baz::Works, fails: Baz::BarStruct, also_fails: Baz::NewType) -> pub Field {
   │                                                                    -------
   │

To Reproduce

Installation Method

None

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@sirasistant sirasistant added the bug Something isn't working label Dec 20, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Dec 20, 2023
@sirasistant sirasistant changed the title Re exports don't work Re-exports don't work Dec 20, 2023
@kevaundray
Copy link
Contributor

@guipublic assigning you as you worked on the original re-export issue

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

## Problem\*

Resolves #3889

## Summary\*

An import of an imported object in the same file would not work because
the imports are added to the module after they are resolved. To fix this
we simply process the imports one-by-one.

## Additional Context



## Documentation\*

Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** 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 Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants