From 3a45998f0ffe617cec2e7e63ddda4e06c1d833bf Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Wed, 30 Sep 2026 16:03:44 +0100 Subject: [PATCH] iterator_drop: a typed Set's finished iterator has value 0 With the compiler inferring a generic class's type arguments from its constructor's arguments, `new Set([1, 2, 3])` is a Set rather than Set, and a finished iterator's value cannot be undefined: it is 0 (garbage until the same compiler PR made an unset value zero). The last case asserts `done` and that value instead of the `any` Set's printed text. Co-Authored-By: Claude Opus 5.5 --- tests/iterator_drop.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/iterator_drop.ts b/tests/iterator_drop.ts index 4d35aa3..53828f6 100644 --- a/tests/iterator_drop.ts +++ b/tests/iterator_drop.ts @@ -38,9 +38,11 @@ for (const n of fibonacci().take(5).drop(2)) { } // 5 +// `new Set([1, 2, 3])` is a Set: a finished iterator's value cannot be undefined, and is 0 const result = new Set([1, 2, 3]).values().drop(4).next(); console.log(result); -assert(result == "{ value: undefined, done: true }"); +assert(result.done); +assert(result.value == 0); console.log("ALL DONE");