diff --git a/ast-passes/src/canonicalization/canonicalizer.rs b/ast-passes/src/canonicalization/canonicalizer.rs index dc6340b1d5..704231cc66 100644 --- a/ast-passes/src/canonicalization/canonicalizer.rs +++ b/ast-passes/src/canonicalization/canonicalizer.rs @@ -470,15 +470,15 @@ impl Canonicalizer { fn canonicalize_function_input(&mut self, input: &FunctionInput) -> FunctionInput { if let FunctionInput::Variable(variable) = input { - if variable.type_.is_self() { - return FunctionInput::Variable(FunctionInputVariable { - identifier: variable.identifier.clone(), - const_: variable.const_, - mutable: variable.mutable, - type_: Type::Identifier(self.circuit_name.as_ref().unwrap().clone()), - span: variable.span.clone(), - }); - } + let type_ = self.canonicalize_self_type(Some(&variable.type_)).unwrap(); + + return FunctionInput::Variable(FunctionInputVariable { + identifier: variable.identifier.clone(), + const_: variable.const_, + mutable: variable.mutable, + type_, + span: variable.span.clone(), + }); } input.clone() diff --git a/tests/compiler/circuits/big_self_in_circuit_replacement.leo b/tests/compiler/circuits/big_self_in_circuit_replacement.leo index 7f0e58b378..74ebb27854 100644 --- a/tests/compiler/circuits/big_self_in_circuit_replacement.leo +++ b/tests/compiler/circuits/big_self_in_circuit_replacement.leo @@ -20,7 +20,7 @@ circuit Foo { y[Self {x: 0}.x] += 2; } - function func() { + function func(a: [Self; 3], y: (Self)) { const x: Self = Foo {x: Self {x: 1}.x}; } diff --git a/tests/expectations/compiler/compiler/circuits/big_self_in_circuit_replacement.leo.out b/tests/expectations/compiler/compiler/circuits/big_self_in_circuit_replacement.leo.out index 2e4b00f7fa..83bd6cd44c 100644 --- a/tests/expectations/compiler/compiler/circuits/big_self_in_circuit_replacement.leo.out +++ b/tests/expectations/compiler/compiler/circuits/big_self_in_circuit_replacement.leo.out @@ -16,7 +16,7 @@ outputs: r0: type: bool value: "true" - initial_ast: d8ff1c8c84bc93bbd4e712dde7eb3c9dbe433199f5902b6dc3329cf3ca607811 - imports_resolved_ast: d8ff1c8c84bc93bbd4e712dde7eb3c9dbe433199f5902b6dc3329cf3ca607811 - canonicalized_ast: 9ef4d52afc2cbbcaa7759af48d1603feb28287d619293135a7856625a37299f7 - type_inferenced_ast: f3a91e1cd91f60c94ffe809369eeecb2f22996b6f14c1589a5c7a825519a6b1e + initial_ast: ec52d3b3e69bef6d104f2dcfa9e713a728d7b0e15439c9da3b521b6cbfe719d4 + imports_resolved_ast: ec52d3b3e69bef6d104f2dcfa9e713a728d7b0e15439c9da3b521b6cbfe719d4 + canonicalized_ast: c85604dd75a964f7a6cfc0dddbeeeccf28a7c43915b944740528a0ff6230db78 + type_inferenced_ast: 258670051ac595a600362cb5a6793fb5ba9361cd914f7483057ad66204fc1b36