diff --git a/bend2/main.ts b/bend2/main.ts index 247767b0c..2fb8da1d2 100755 --- a/bend2/main.ts +++ b/bend2/main.ts @@ -351,7 +351,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. +// 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,7 +374,7 @@ 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/ + 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) { 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");