Files
scriptc/tests/coverage-fixtures/unreached.ts
T
Chris Tate 4e5864bed4 Iterate generators from Symbol.asyncIterator and check return() results in for await
A Symbol.asyncIterator method that returns a compiled generator is iterated
instead of refused. Async yield* awaits a synchronous delegate's final value,
and return() results that are not objects throw V8's TypeError, which names
primitive results. The coverage fixture drops its async yield* example, which
now compiles.
2026-10-20 18:16:20 -05:00

25 lines
635 B
TypeScript

// A program whose ENTRY PATH is fully static while an unused corner is
// not: builds succeed (unreached bodies never lower), and the report
// shows the corner's blockers in the dim "in unreached code" group.
function used(n: number): number {
return n + 1;
}
class Bag {
size = 0;
}
// Never called: the class-instance for-in and the labeled jump into a
// desugared loop can't fail a build.
function unusedCorner(bag: Bag, pairs: Map<string, number>): void {
for (const k in bag) {
console.log(k);
}
outer: for (const [k, v] of pairs) {
if (v > 0) break outer;
console.log(k);
}
}
console.log(used(41));