Skip to content

Commit 99ace2b

Browse files
committed
fix nested write merge
1 parent ed6dad0 commit 99ace2b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/cmd/info.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ export default async function cmdInfo(args: InfoArgs) {
1414

1515
const agg = aggregateImports(p);
1616
const block = createBlock(...agg.rest);
17-
const analysis = analyzeBlock(block);
17+
const analysis = analyzeBlock(block, { nest: true });
1818
resolveConst(agg, analysis);
1919

20+
console.info('analysis:', analysis.vars);
21+
2022
const toplevelVars = new Map<string, VarInfo>();
2123
const nestedVars = new Map<string, VarInfo>();
2224
for (const [cand, info] of analysis.vars) {
@@ -59,6 +61,8 @@ export default async function cmdInfo(args: InfoArgs) {
5961
suffix = ` from ${JSON.stringify(e.import)} (re-export)`;
6062
} else if (!agg.localConst.has(e.name)) {
6163
suffix = ` (mutable, may change)`;
64+
} else {
65+
suffix = ` (const)`;
6266
}
6367
console.info(`- ${left}${suffix}`);
6468
}

lib/internal/analyze/block.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export function analyzeBlock(b: acorn.BlockStatement, args?: { nest?: boolean })
264264

265265
if (info.nested) {
266266
prev.nested ??= { writes: 0 };
267-
prev.nested.writes += prev.nested.writes;
267+
prev.nested.writes += info.nested.writes;
268268
}
269269
}
270270
break;

0 commit comments

Comments
 (0)