Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -45183,6 +45183,7 @@ static JSValue js_iterator_proto_func(JSContext *ctx, JSValueConst this_val,
}
break;
}
JS_FreeValue(ctx, item);
index_val = JS_UNDEFINED;
ret = JS_UNDEFINED;
item = JS_UNDEFINED;
Expand Down
18 changes: 18 additions & 0 deletions tests/bug1572.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { assert } from "./assert.js";

// Every element takes the non-matching path (the predicate is never true).
{
const o = {};
assert([o, o, o].values().find(() => false), undefined);
assert(new Array(1000).fill(o).values().find(() => false), undefined);
}

// The match path still returns the first match and forwards (value, index).
{
const seen = [];
const r = [10, 20, 30, 40].values().find((v, i) => { seen.push(v, i); return v === 30; });
assert(r, 30);
assert(seen.length, 6); // stopped at the third element
assert(seen[0], 10); assert(seen[1], 0);
assert(seen[4], 30); assert(seen[5], 2);
}
Loading