diff options
| author | 2026-10-14 07:55:08 +0000 | |
|---|---|---|
| committer | 2026-10-14 07:55:08 +0000 | |
| commit | d8da21a406f449d277c42b91d4c9bf8b20bd0dcc (patch) | |
| tree | 79a4dbf6839eaee19aa626f1aa3981d5b0c19377 /docs/BOOTSTRAP-OWNERSHIP.md | |
| parent | build: embed images with #embed, keep everything generated in build/ (diff) | |
embed: tests, editor support and docs; js vm file access; test fixes
embed declarations get accept and reject fixtures, a run-only image check
through zc0, an lsp keyword hover and the grammar keyword. errors point at
the declaration and still declare the name, so its uses are not reported
again. zc0 tracks byte-string globals and lays embedded arrays out one word
per element, the way its own indexing reads them.
the command-line javascript vm reaches node's file system for the file
syscalls, so include and embed work there; other embedders opt in.
the web build is self-contained in build/web with its examples. README,
BORROW and BOOTSTRAP-OWNERSHIP describe the new build and ownership rules,
and ONBOARD.md is a reading and verification order for the code.
the suite passes the map header to mklayout, the wasm fuzz program uses
the include format, and lsp drivers scale their deadlines on hosts
without the arm64 jit (ZC_TEST_TIMEOUT_SCALE). LLVM_CONFIG selects an
llvm with headers for the llvm section.
Diffstat (limited to 'docs/BOOTSTRAP-OWNERSHIP.md')
| -rw-r--r-- | docs/BOOTSTRAP-OWNERSHIP.md | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/docs/BOOTSTRAP-OWNERSHIP.md b/docs/BOOTSTRAP-OWNERSHIP.md index 509db2f..6cc61ce 100644 --- a/docs/BOOTSTRAP-OWNERSHIP.md +++ b/docs/BOOTSTRAP-OWNERSHIP.md @@ -1,7 +1,9 @@ -# the bootstrap does not compile: owned values cannot be moved between locals +# the bootstrap did not compile: owned values could not be moved between locals -status: open, blocks `make` -affects: `make genome`, the `fixpoint` check, the `genome.h is up to date` check +status: resolved. the analyzer gained the two rules proposed below and a clearer +recast diagnostic, and `make genome` reaches its fixpoint from a clean checkout. +see "resolution" at the end; the rest of this note is the record of the problem. +affects: `make genome` and the `fixpoint` check see also: `docs/BORROW.md` ## summary @@ -10,7 +12,7 @@ see also: `docs/BORROW.md` `src/core/core.zc` and `src/compiler/compiler.zc` into a stage-0 image, stage-0 becoming `build/zy0`, and `zy0` compiling the same three files again into the genome. the second compilation runs with lifetime checking enabled and rejects -the compiler's own source. `bin/mkgenome` then reads the diagnostics as if they +the compiler's own source. `mkgenome` then read the diagnostics as if they were an image: ``` @@ -152,4 +154,30 @@ reports. bash src/tools/bootstrap-check.sh ``` -a passing run prints `image ok: <n> bytes`.
\ No newline at end of file +a passing run prints `image ok: <n> bytes`. + +## resolution + +the analyzer (`src/compiler/compiler.zc`) now accepts the three spellings: + +1. **moves into a released owner.** `rt.free(r); r = joined;` moves `joined` into `r` + when `r` was released first and `joined` is an owner of the same block or a deeper + one. `joined` is retired by the move. a destination that still owns something is + still rejected (`still owns an object; overwriting it would leak it`), and so is a + copy of an owner into a fresh declaration. +2. **bounded lends to globals.** `g = m*x;` with `x` an owned local lends `x` to `g`: + `x` keeps ownership and stays usable, and the lend ends when the same block assigns + `g` again. giving `x` away, returning, breaking or leaving the block while the lend + is open is an error (`is lent to global g; assign the global again before ...`). the + lend list is per function and per block depth (`lend_add`, `lend_clear`, + `lend_exit`), so a restore inside a nested branch does not end a lend made outside it. +3. **recasts of plain locals.** `rt.code_blocks = m*block;` failed because `block` came + from `chk_resize`, which returns collector-managed storage, so `block` never owned + anything. the compiler now writes `rt.code_blocks = block;`, and a recast of a plain + local reports `block: isn't an owned object, so there is no ownership to recast` + instead of the old message. + +`methdef` uses the lend for its scratch buffer and the move for the joined token list. +the regressions are `tests/programs/ownmove.zc` and `tests/errors/lend_*.zc`, +`recast_plain.zc` and `move_live_owner.zc`. + |
