-
Notifications
You must be signed in to change notification settings - Fork 252
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: nargo expand
to show code after macro expansions
#7613
base: master
Are you sure you want to change the base?
Conversation
How would we do this though? The reason we only have a CLI flag currently and only output the new code is that while we're elaborating we are losing information about the source code. We throw away all type and trait definitions for example. By monomorphization we're already left with only functions. How would we output any types/traits/imports/etc back into the program? I don't think just skipping past them is an option either since metaprogramming may modify a type definition such that it differs from the source. |
Oh, I just meant that if we have a function
They are in the NodeInterner, for example
Right, we can do this before monomoprhization (or put another way: we don't monomorphize for this tool) |
I can't get past this wall. There's this code: trait LibTrait<N> {
fn broadcast();
fn get_constant() -> Field;
}
pub struct StructA;
impl LibTrait<u32> for StructA {
fn broadcast() {
let _ = Self::get_constant();
}
fn get_constant() -> Field {
1
}
}
fn main() {} In this call: Self::get_constant()
|
@noir-lang/core This is ready for review again. I added tests so that |
Description
Problem
Resolves #7552
Summary
By pure coincidence,
nargo expand
works almost the same way ascargo expand
:cargo expand
)cargo expand
)In a follow-up PR we could try to somehow put back comments (we can know where they are and insert them as we traverse the HIR).
For example, if you run it for this code:
we get this output:
Additional Context
Documentation
Check one:
PR Checklist
cargo fmt
on default settings.