Skip to content

One-liner code is statements; let-only entry file explains missing main (#1816) - #1938

Merged
ehartford merged 2 commits into
win-self-containedfrom
fix-1816
Sep 30, 2026
Merged

ehartford merged 2 commits into
win-self-containedfrom
fix-1816

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes #1816. with -e 'let x = 1' runs (one-liner/REPL entry is statements by construction, §18.5b); a let-only entry file fails with a clear diagnostic instead of undefined symbol: _main. Regression test red on the installed compiler, green on stage1; gate green. Joins the next batch stack.

…nly entry file says why it has no main (#1816)

A CLI one-liner (and a REPL line) is top-level executable statements by
construction (§18.5b), so its top-level `let`/`var`s are main's locals even
when nothing else is there. Before, `with -e 'let x = 1'` read the `let` as a
module global, produced no main, and died in the linker with
"undefined symbol: _main".

An entry file of only `let`s stays a module of globals (D74); building it as a
program now fails with "has no `fn main` and no top-level statement to run"
instead of the raw link error.

Test: behav_1816_let_only_entry.w fails on the installed compiler (the lld
_main error) and passes on stage1. Gate green.
@ehartford
ehartford changed the base branch from main to win-self-contained September 30, 2026 13:05
@ehartford
ehartford added this pull request to stack #1940 September 30, 2026 13:05
… block or a refusal

`static inline void f(void) {}` was refused ("inline body translation
failed"): ci_trans_stmt_via_ir answered "" both when a statement failed to
lower and when it lowered to nothing, so an empty body read as a failure.
Once ff95562 read a cast to Unit as void, `{ (void)d; }` lowered to a
blank body and printed `-> Unit:` with nothing under it — a parse error
that turned behav_c_import_opaque_member_receiver red in the #1940 battery.

ci_trans_stmt_ir now says whether the statement lowered, apart from its
text. A lowered void body with no text is `return`; a non-void body with
nothing to return still has no translation, and a failed lowering still
fails.

Test: behav_c_import_empty_void_body.w fails on the pre-fix compiler (the
parse error) and passes on stage1; behav_c_import_opaque_member_receiver
passes again.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on stack top d55a6aa (seed-driven, with run tools/battery.w): gate rc=0, battery-checks rc=0 wall=373s. First run on 202b11e was RED (behavior-tests: behav_c_import_opaque_member_receiver — empty void C body emitted as -> Unit: with no body); fixed in d55a6aa with regression test behav_c_import_empty_void_body.w.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

with -e: a program of only let statements links with no main ("_main" undefined) instead of running as an implicit main

1 participant