This program should compile successfully with some_wrapped_value being equal to FooStruct { inner: 0 }.
Bug
Compilation fails with the error below:
$ nargo execute
error: Could not resolve 'FooStruct' in path
┌─ /home/tom/Programming/aztec/noir/test_programs/execution_success/global_consts/src/main.nr:80:13
│
80 │ FooStruct { inner: 0 }
│ ---------
│
Aborting due to 1 previous error
To Reproduce
copy-paste above code into program with an empty fn main() {} and compile
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
This bug seems to specifically hit static methods on structs which are being referred to using full path as opposed to being imported into the current module as the following programs compile:
FooStruct is imported into current module:
global some_wrapped_value: FooStruct = FooStruct::new();
use thing::FooStruct;
mod thing {
struct FooStruct {
inner: Field
}
impl FooStruct {
pub fn new() -> Self {
FooStruct { inner: 0 }
}
}
}
some_wrapped_value is being initialized to be equal to a FooStruct constructed in the same module as where it is defined.
global some_wrapped_value: thing::FooStruct = thing::foo_thing;
mod thing {
global foo_thing: FooStruct = FooStruct::new();
struct FooStruct {
inner: Field
}
impl FooStruct {
pub fn new() -> Self {
FooStruct { inner: 0 }
}
}
}
Aim
I would like to create a
global
by calling a static method on a struct which is defined in another module.My program is then
Expected Behavior
This program should compile successfully with
some_wrapped_value
being equal toFooStruct { inner: 0 }
.Bug
Compilation fails with the error below:
To Reproduce
copy-paste above code into program with an empty
fn main() {}
and compileProject Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
This bug seems to specifically hit static methods on structs which are being referred to using full path as opposed to being imported into the current module as the following programs compile:
FooStruct
is imported into current module:some_wrapped_value
is being initialized to be equal to aFooStruct
constructed in the same module as where it is defined.Installation Method
None
Nargo Version
No response
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response