fix(semantics): preserve direct promise ownership boundaries (#758)

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
Rudy Mizrahi Celekli authored and GitHub committed 2026-10-07 02:36:41 +08:00
1 parent 66c26f280b
commit e1ca412757
3 files changed
+124 -8

No files matched your search

@@ -286,3 +286,27 @@ const graphFor = (source: string) => {
analysis,
});
};
it.each([
"const value = consume(Promise.resolve(1));",
"async function run() { await consume(Promise.resolve(1)); }",
"function run() { return consume(Promise.resolve(1)); }",
"const value = Promise.all([{ promise: Promise.resolve(1) }]);",
])(
"does not claim direct Promise ownership through an enclosing expression: %s",
(source) => {
const graph = graphFor(source);
const promise = graph.nodes.find(
({ kind, properties }) =>
kind === "promise" && properties.method === "resolve",
);
expect(promise?.properties.ownership).toBe("unknown");
expect(
graph.relations.filter(
({ target_node_id, relation }) =>
target_node_id === promise?.node_id &&
["owns", "awaits", "returns-task", "aggregates"].includes(relation),
),
).toEqual([]);
},
);