mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
`target.push(...items)` passes every item as a call argument and overflows the stack once a target-sized array grows past the engine's argument limit. This class was fixed one site at a time in #10304, #10343, #10362 and #8632. Add one shared appendAll helper in src/domain and use it at the remaining sites whose arrays grow with the input: XML member counting, app-task row suggestions, native call routes and unresolved calls, call-path caveats, environment-manifest merges, reference-source import entries, dyld trace edges and JS symbolic flow values. The web bundle merge from the previous commit now uses the shared helper too. Bounded spreads (fixed literals, page-sized reads) are left as they are. Refs #10445 Refs #10342 Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
18 lines
600 B
TypeScript
18 lines
600 B
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { appendAll } from "./appendAll.js";
|
|
|
|
it("appends an array wider than any call-argument limit", () => {
|
|
// Where `push(...wide)` overflows depends on the engine's stack; a loop
|
|
// has no such limit.
|
|
const wide = Array.from({ length: 2_000_000 }, (_, index) => index);
|
|
const target = [-1];
|
|
expect(appendAll(target, wide)).toBe(target);
|
|
expect(target).toHaveLength(2_000_001);
|
|
expect(target.at(-1)).toBe(1_999_999);
|
|
});
|
|
|
|
it("appends any iterable in order", () => {
|
|
expect(appendAll(["a"], new Set(["b", "c"]))).toEqual(["a", "b", "c"]);
|
|
});
|