From 962faa5f8c09727dd85b016410fb70f09e909f98 Mon Sep 17 00:00:00 2001 From: toprameen <11931132+toprameen@users.noreply.github.com> Date: Tue, 17 Nov 2026 12:24:31 -0800 Subject: [PATCH 1/3] fix(cli): preserve Base import order in checkup --- bend2/main.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bend2/main.ts b/bend2/main.ts index 247767b0c..06b1749eb 100755 --- a/bend2/main.ts +++ b/bend2/main.ts @@ -350,8 +350,8 @@ async function cli_file(args: string[]): Promise { } } -// cli_checkup checks and runs each import of the file alone (Base read -// once, seeded into every module that imports it); one that fails fails it. +// cli_checkup checks and runs each import of the file alone; one that fails +// fails it. Seed the checked Base only where the loader would read Base first. async function cli_checkup(file: string): Promise { const base = await book_read(BASE); let bad = false; @@ -373,8 +373,9 @@ async function cli_checkup(file: string): Promise { cli_say(1, "--- " + m[1] + " ---\n"); let code = 1; try { - const own = /^(?:[\t\r ]*(?:(?:#|import )[^\n]*)?\n)*[\t ]*import Base\s/ - .test(fs.readFileSync(at, "utf8")); + const first = fs.readFileSync(at, "utf8").split("\n") + .find((line) => !/^\s*(?:#|$)/.test(line))?.trim(); + const own = /^import\s+Base(?:\s+#.*)?$/.test(first ?? ""); code = book_run(await book_read(at, own ? base : undefined), [at]); } catch (e) { cli_say(2, book_err(e) + "\n"); From 1d6765b7d6f8888f1d8fbd068478dd4ce732bec4 Mon Sep 17 00:00:00 2001 From: toprameen <11931132+toprameen@users.noreply.github.com> Date: Tue, 17 Nov 2026 12:24:31 -0800 Subject: [PATCH 2/3] test(cli): check late Base imports in checkup --- gates/ping.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gates/ping.ts b/gates/ping.ts index 32c30286d..5ab4fdd99 100644 --- a/gates/ping.ts +++ b/gates/ping.ts @@ -373,6 +373,14 @@ try { { BEND_NO_TELEMETRY: "1" }); check("--checkup gives Base only to a module that imports it", base_run.code === 1); + const late_base = path.join(TMP, "late-base.bend"); + fs.writeFileSync(late_base, + "import ./no-base.bend as NoBase\nimport Base\ndef main() -> Nat:\n 0n\n"); + fs.writeFileSync(header_source, "import ./late-base.bend as LateBase\n"); + const late_base_run = await bend([header_source, "--checkup"], + { BEND_NO_TELEMETRY: "1" }); + check("--checkup checks a dependency before a later import of Base", + late_base_run.code === 1 && late_base_run.err.includes("- observed : String")); fs.writeFileSync(path.join(TMP, "page.html"), "\n"); fs.writeFileSync(path.join(TMP, "page.ts"), "import \"./none.ts\";\n"); From d22a93593f8276d9bab43ee8548f5e5ebe259479 Mon Sep 17 00:00:00 2001 From: Nico Abril Date: Wed, 18 Nov 2026 18:50:39 +0100 Subject: [PATCH 3/3] refactor(cli): checkup's Base test drops the import skip from the old regex Co-Authored-By: Claude Opus 5.5 --- bend2/main.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bend2/main.ts b/bend2/main.ts index 06b1749eb..2fb8da1d2 100755 --- a/bend2/main.ts +++ b/bend2/main.ts @@ -350,8 +350,9 @@ async function cli_file(args: string[]): Promise { } } -// cli_checkup checks and runs each import of the file alone; one that fails -// fails it. Seed the checked Base only where the loader would read Base first. +// cli_checkup checks and runs each import of the file alone (Base read +// once, seeded into every module whose first import is Base, as the loader +// would read it); one that fails fails it. async function cli_checkup(file: string): Promise { const base = await book_read(BASE); let bad = false; @@ -373,9 +374,8 @@ async function cli_checkup(file: string): Promise { cli_say(1, "--- " + m[1] + " ---\n"); let code = 1; try { - const first = fs.readFileSync(at, "utf8").split("\n") - .find((line) => !/^\s*(?:#|$)/.test(line))?.trim(); - const own = /^import\s+Base(?:\s+#.*)?$/.test(first ?? ""); + const own = /^(?:[\t\r ]*(?:#[^\n]*)?\n)*[\t ]*import Base\s/ + .test(fs.readFileSync(at, "utf8")); code = book_run(await book_read(at, own ? base : undefined), [at]); } catch (e) { cli_say(2, book_err(e) + "\n");