driver: implement post-target run argv semantics

This commit is contained in:
2026-08-23 17:33:31 +09:00
parent 0b24b11d65
commit 29122f2a48
6 changed files with 579 additions and 17 deletions

View File

@@ -703,6 +703,32 @@ ImportPath = ident { "." ident } .
arguments and result; this rule does not adopt Go's source signature. An
ordinary import of a package declared `main` is rejected, except for the
toolchain's colocated external-test wiring.
- For `ww run`, the first explicit non-option operand selects the one run
target. Every later operand is program input and is passed unchanged and in
order after the private executable's `argv[0]`; it is not reparsed as a
driver option. This includes known or unknown option spellings, would-be
option values, a lone `--`, empty arguments, ordinary nonflags, and later
`.ww` spellings. A later `.ww` is therefore argv, not another source in a
command-line package; multiple named sources remain unsupported. Registered
driver options before the target retain their established spelling, value,
repetition, and diagnostic rules. A leading or otherwise pre-target `--`
retains WW's exact unknown-flag rejection rather than acting as a general
terminator. With no explicit target, `ww run` retains its implicit current-
directory selection and has no post-target suffix.
Only the selected target and pre-target driver options affect resolution,
source loading, package/import identity, graph construction, compiler,
assembler, archiver, linker, private executable bytes, reuse, or
invalidation. A missing, invalid, non-main, or producer-failing target
diagnoses before runtime and no suffix spelling can mask that result. A
successful private link executes with the exact suffix and retains WW's
existing stdout, stderr, and exact child-status propagation. The private run
product is removed normally and publishes no executable or persistent
semantic state. `ww build`, every `ww test` route, package membership, and
dotted import semantics are unchanged. Direct roots remain `__root.*`,
dotted directories retain dotted identity, and argv never becomes package,
import, action, symbol, artifact, `.wwi`, publication, or persistence
identity. Build workdir format remains 18, test workdir format remains 19,
and semantic storage format remains 3.
- For `ww build`, the output-option name is exactly `o`. The accepted forms are
`-o VALUE`, `--o VALUE`, `-o=VALUE`, and `--o=VALUE`. An equals form splits
at its first `=` and preserves every later byte, including further `=`