Skip to content

Commit

Permalink
handle transient dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusarich committed Jul 11, 2024
1 parent 46fc0a8 commit f75dad6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/test/e2e-emulated/contracts/abi.tact
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {}
}
20 changes: 18 additions & 2 deletions src/types/resolveDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f75dad6

Please sign in to comment.