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
5 changes: 3 additions & 2 deletions bend2/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ async function cli_file(args: string[]): Promise<void> {
}

// 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<void> {
const base = await book_read(BASE);
let bad = false;
Expand All @@ -373,7 +374,7 @@ async function cli_checkup(file: string): Promise<void> {
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) {
Expand Down
8 changes: 8 additions & 0 deletions gates/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
"<script type=\"module\" src=\"./page.ts\"></script>\n");
fs.writeFileSync(path.join(TMP, "page.ts"), "import \"./none.ts\";\n");
Expand Down