From f75dad6da09bd28257ea4f861f6252841f4a3dfb Mon Sep 17 00:00:00 2001 From: Gusarich Date: Thu, 11 Jul 2024 20:54:52 +0300 Subject: [PATCH] handle transient dependencies --- src/test/e2e-emulated/contracts/abi.tact | 24 ++++++++++++++++++++++++ src/types/resolveDescriptors.ts | 20 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/test/e2e-emulated/contracts/abi.tact b/src/test/e2e-emulated/contracts/abi.tact index 9d5e59e74..f59f61eac 100644 --- a/src/test/e2e-emulated/contracts/abi.tact +++ b/src/test/e2e-emulated/contracts/abi.tact @@ -12,6 +12,16 @@ struct S3 { z: Int; } +struct S4 { + a: Int; + s: S; +} + +message M1 { + a: Int; + s: S4; +} + fun testS3(): Int { let s3 = S3 { z: 123 }; return s3.z; @@ -57,4 +67,18 @@ contract D with Deployable { get fun test(): Int { return testS3(); } +} + +contract E with Deployable { + receive() {} + + get fun test(s: S4): Int { + return s.a; + } +} + +contract F with Deployable { + receive() {} + + receive(msg: M1) {} } \ No newline at end of file diff --git a/src/types/resolveDescriptors.ts b/src/types/resolveDescriptors.ts index 2eda3825e..66bce4fe4 100644 --- a/src/types/resolveDescriptors.ts +++ b/src/types/resolveDescriptors.ts @@ -1799,7 +1799,15 @@ export function resolveDescriptors(ctx: CompilerContext) { if (!structDependencies.has(name)) { structDependencies.set(name, new Set()); } - structDependencies.get(name)!.add(types.get(idText(src))!); + structDependencies.set( + name, + new Set([ + ...structDependencies.get(name)!, + types.get(idText(src))!, + ...(structDependencies.get(idText(src)) ?? + new Set()), + ]), + ); } } else if (src.kind === "init_of") { if (types.get(idText(src.contract))?.kind === "contract") { @@ -1872,7 +1880,15 @@ export function resolveDescriptors(ctx: CompilerContext) { if (!structDependencies.has(k)) { structDependencies.set(k, new Set()); } - structDependencies.get(k)!.add(types.get(f.selector.type)!); + structDependencies.set( + k, + new Set([ + ...structDependencies.get(k)!, + types.get(f.selector.type)!, + ...(structDependencies.get(f.selector.type) ?? + new Set()), + ]), + ); } } traverse(f.ast, handler);