diff --git a/Cargo.lock b/Cargo.lock
index 65c51a0a5c3..97e441a6a3b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1924,6 +1924,7 @@ dependencies = [
"leo-disassembler",
"leo-errors",
"leo-parser",
+ "leo-passes",
"leo-span",
"leo-test-framework",
"rand",
@@ -1961,6 +1962,7 @@ dependencies = [
"leo-errors",
"leo-interpreter",
"leo-package",
+ "leo-passes",
"leo-span",
"libc",
"nix",
diff --git a/Cargo.toml b/Cargo.toml
index 99dc2e57801..dd1fbc36e27 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -199,6 +199,9 @@ workspace = true
[dependencies.leo-package]
workspace = true
+[dependencies.leo-passes]
+workspace = true
+
[dependencies.leo-span]
workspace = true
diff --git a/compiler/ast/src/expressions/mod.rs b/compiler/ast/src/expressions/mod.rs
index c8b97e21d08..e724dce9588 100644
--- a/compiler/ast/src/expressions/mod.rs
+++ b/compiler/ast/src/expressions/mod.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see .
-use crate::{CoreFunction, Identifier, IntegerType, Node, NodeBuilder, NodeID, Path, Type};
+use crate::{CoreFunction, Identifier, IntegerType, Location, Node, NodeBuilder, NodeID, Path, Type};
use leo_span::{Span, Symbol};
use serde::{Deserialize, Serialize};
@@ -400,7 +400,8 @@ impl Expression {
ty: &Type,
span: Span,
node_builder: &NodeBuilder,
- struct_lookup: &dyn Fn(&[Symbol]) -> Vec<(Symbol, Type)>,
+ current_program: Symbol,
+ struct_lookup: &dyn Fn(&Location) -> Vec<(Symbol, Type)>,
) -> Option {
let id = node_builder.next_id();
@@ -444,13 +445,16 @@ impl Expression {
// Structs (composite types)
Type::Composite(composite_type) => {
let path = &composite_type.path;
- let members = struct_lookup(&path.absolute_path());
+ let members = struct_lookup(&Location::new(
+ composite_type.program.unwrap_or(current_program),
+ path.absolute_path(),
+ ));
let struct_members = members
.into_iter()
.map(|(symbol, member_type)| {
let member_id = node_builder.next_id();
- let zero_expr = Self::zero(&member_type, span, node_builder, struct_lookup)?;
+ let zero_expr = Self::zero(&member_type, span, node_builder, current_program, struct_lookup)?;
Some(StructVariableInitializer {
span,
@@ -474,7 +478,7 @@ impl Expression {
Type::Array(array_type) => {
let element_ty = &array_type.element_type;
- let element_expr = Self::zero(element_ty, span, node_builder, struct_lookup)?;
+ let element_expr = Self::zero(element_ty, span, node_builder, current_program, struct_lookup)?;
Some(Expression::Repeat(
RepeatExpression { span, id, expr: element_expr, count: *array_type.length.clone() }.into(),
diff --git a/compiler/ast/src/interpreter_value/value.rs b/compiler/ast/src/interpreter_value/value.rs
index 6d5103ecfd7..4748c7fde0b 100644
--- a/compiler/ast/src/interpreter_value/value.rs
+++ b/compiler/ast/src/interpreter_value/value.rs
@@ -827,8 +827,9 @@ impl Value {
&self,
span: Span,
node_builder: &NodeBuilder,
+ current_program: Symbol,
ty: &Type,
- struct_lookup: &dyn Fn(&[Symbol]) -> Vec<(Symbol, Type)>,
+ struct_lookup: &dyn Fn(&Location) -> Vec<(Symbol, Type)>,
) -> Option {
use crate::{Literal, TupleExpression, UnitExpression};
@@ -850,7 +851,7 @@ impl Value {
elements: vec
.iter()
.zip(tuple_type.elements())
- .map(|(val, ty)| val.to_expression(span, node_builder, ty, struct_lookup))
+ .map(|(val, ty)| val.to_expression(span, node_builder, current_program, ty, struct_lookup))
.collect::