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

Add Module::add_item #5875

Closed
jfecher opened this issue Aug 30, 2024 · 3 comments · Fixed by #5943 or #5947
Closed

Add Module::add_item #5875

jfecher opened this issue Aug 30, 2024 · 3 comments · Fixed by #5943 or #5947
Assignees
Labels
enhancement New feature or request

Comments

@jfecher
Copy link
Contributor

jfecher commented Aug 30, 2024

Problem

(From a slack request)

Given just a Module metaprogramming object, there is no way to add additional functions or types to the module.

Happy Case

We add the function:

impl Module {
    fn add_item(self, item: Quoted) {}
}

To add a top-level item to the module.

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher jfecher added the enhancement New feature or request label Aug 30, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 30, 2024
@asterite
Copy link
Collaborator

asterite commented Sep 5, 2024

I was actually wondering if this should be the only way to add new items to a program.

For example, if you have two annotations on a module:

#[one]
mod foo {
  #![two]
}

if there are functions one and two that return a Quoted value, where do they get inserted? I think right now for one it's inserted in foo's parent, but for two it's inserted in foo... but maybe that's expected?

@jfecher
Copy link
Contributor Author

jfecher commented Sep 5, 2024

@asterite I think I would expect both to be inserted within foo. We should have inner attributes just be a syntax thing that are otherwise equivalent to being on the module itself.

@asterite
Copy link
Collaborator

asterite commented Sep 5, 2024

Sounds good, I'll capture an issue for this and likely work on it today.

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

## Problem

Resolves
#5875 (comment)

## Summary



## Additional Context



## Documentation

Check one:
- [x] No documentation needed.
- [ ] 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.

---------

Co-authored-by: jfecher <jake@aztecprotocol.com>
Co-authored-by: Jake Fecher <jfecher11@gmail.com>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Sep 5, 2024
@asterite asterite reopened this Sep 5, 2024
@asterite asterite self-assigned this Sep 5, 2024
@asterite asterite mentioned this issue Sep 5, 2024
5 tasks
github-merge-queue bot pushed a commit that referenced this issue Sep 6, 2024
# Description

## Problem

Resolves #5875

## Summary


## Additional Context



## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
2 participants