Skip to content

Sema: the field-move path is a record, not an i64 with a 16-bit start — text-sensitive false "use of moved value" on a sibling field after a field move (#1631) - #1656

Merged
ehartford merged 1 commit into
mainfrom
sema-field-move-path
Sep 25, 2026
Merged

ehartford merged 1 commit into
mainfrom
sema-field-move-path

Conversation

@ehartford

@ehartford ehartford commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the packed field-move path with FieldMovePath { base_sym, path_start, path_count }. Previously the append-only path arena's start occupied only 16 bits of an i64; consumers masked it with & 65535. Above 65,535 entries, move checking read an unrelated earlier path and could report a sibling field as moved. The answer changed with unrelated source text (#1631/#1634).

The recorded failing case had base=actual_options, packed_start=66323, masked_start=787, borrow_path_data_len=66324, followed by a false use-of-moved-value error at src/main.w:3003:58. The record preserves the full arena index and count in all three consumers: marking, querying, and clearing moved fields.

Part 1 of GitHub stack #1664: #1656 → #1661 → #1662. The 70,000-read arena regression is included in the stack. The seed still has the packing bug, so #1661 carries one explicitly marked source accommodation; retire it after cutting a seed containing this fix.

Validation of the corrected stack at 974c8ba passed: full seed-driven build, byte-identical fixpoint across 16 units, drop audit (213 cells), move audit (105 cells), full test suite, test-green, and last-green. The singleton-sort panic found by the first battery is fixed in #1662. The final stack verdict table is posted on #1662.

… — a sibling field read after `move s.f` was "use of moved value" whenever unrelated source shifted the path buffer (#1631)

field_move_path_for_expr packed (base_sym, path_start, path_count) into
one i64 with path_start in 16 bits and no mask on it, and the three
consumers (mark_field_moved, field_is_moved,
clear_moved_fields_for_place_expr) unpacked with `& 65535`.
borrow_path_data is append-only for the whole compilation and passes
65535 entries in any compiler-sized check, so a just-collected path was
compared at a stale offset, and the overflow leaked into path_count.
The verdict then depended on what the stale bytes held: a sibling field
read after `move actual_options.output_path` (src/main.w:3003) was
"use of moved value" on one tree and fine on another, with the same
compiler and the same line — and the seed-built stage1 and the stage2
compiler disagreed on the same source (#1631).

Proof, an instrumented field_is_moved on the hit
(`with-stage1 check src/main.w`, main fa33bda + the audit:resolution
branch):

    [field-move-hit] base=actual_options packed_start=66323 masked_start=787 masked_count=1 borrow_path_data_len=66324 entries=1
    error: use of moved value --> src/main.w:3003:58

and on main's own text the same binary:

    [field-move-hit] base=materialized packed_start=65735 masked_start=199 ...
    [field-move-hit] base=actual_options packed_start=66112 masked_start=576 ...
    error: use of moved value --> src/main.w:2008:71

The path is now a FieldMovePath record (base_sym 0 names none); nothing
is packed. A stage1 built from this tree checks main and the
audit:resolution branch `ok`; the pinned seed accepts this tree.
ehartford pushed a commit that referenced this pull request Sep 24, 2026
…he pinned seed carries the 16-bit field-path bug (#1631) that #1656 fixes, and must still compile this tree; retire with the next seed cut
@ehartford
ehartford added this pull request to stack #1664 September 24, 2026 23:18
@ehartford
ehartford marked this pull request as ready for review September 25, 2026 01:42
@ehartford
ehartford merged commit 4f00495 into main Sep 25, 2026
@ehartford
ehartford deleted the sema-field-move-path branch September 25, 2026 03:32
ehartford added a commit that referenced this pull request Sep 25, 2026
…s, and safe libcurl UAT (#1661)

* c_import: `typedef void H;` is `type H = c_void`, never `Unit` — a facade's `resource Easy wraps *mut CURL` must name the type the translated declarations spell

ci_translate_typedef rendered a void typedef as an alias of Unit while every
`H *` parameter and return in the same translation is `*mut c_void`, so
`*mut CURL` (the header's own spelling) never matched curl_easy_init's
return or curl_easy_setopt's first parameter: "producer 'h_new' returns
*mut c_void, not the representation". The alias is c_void — an incomplete
object type C uses only through pointers — and FacadeRender's alias chasing
follows a true c_void alias (it stopped at any target rendering as c_void,
a guard meant for `= opaque`, which is its own declaration kind and never
in the alias loop). Exercised by behav_libcurl_facade_setopt.w and the
libcurl UAT (D66).

* Facade D66: discriminated variadic contracts (`variadic param N selected by param P:` with `case CONST: <type>`) and borrowed record views (`returns borrow T from domain D | from param N`)

Spec §16.2b.5 "Discriminated variadic contracts" and §16.2b.6 "Borrowed
record views" (D66). Parser: the variadic clause with its indented cases; a
callback case and a retained case are refused naming #1652. Sema: the fn
must be variadic, N its variadic position, P an earlier integer or enum
parameter, each case an imported integer constant with a distinct value and
an integer C type or `str` (a pointer case is refused with the two
contracts it lacks); a call's selector must be a compile-time constant (an
integer literal or an imported constant no local shadows) naming a listed
case — otherwise the refusal names the case to add and the raw variadic
function, which stays raw and available under `unsafe`. Render: one method
or function per case, `<name>__<CONST>`, calling the declaration — still
variadic to the backend — with the case's argument typed as the case
states (`str` as a call-scoped NUL-terminated copy, §16.3c); Sema
retargets the presented call to the case its selector picks (check_call
chooses, lower_method_call/lower_call materialize; D65). Record views:
`returns borrow T` for a c_import struct T, from a resource parameter or a
declared domain, renders `Option[&T]` — a lend method with the declared
view summary, or a free bridge reached under the C name — whose scalar
fields are readable, whose pointer fields stay raw, and which the origin's
invalidating operations end; `static` stays CStr-only. Bridges of free
operations now carry the raw operation's call effects (domains touched,
domain borrowed).

Fixtures: ulimit's UL_SETFSIZE long crossing a real variadic ABI and read
back; every refusal; localeconv's record from a domain and a resource-backed
record view, its invalidation by domain and by lend, outliving its origin,
a pointer field used as text needing unsafe.

* lib/facades/libcurl.w: the libcurl facade against the real curl/curl.h — Easy (init/cleanup), setopt case by case, the version record as a borrowed view of the version_info domain, curl_version and curl_easy_strerror static text (D66)

Every clause cites the manual sentence it relies on. The callback pairing
(CURLOPT_WRITEFUNCTION/WRITEDATA) and the retained CURLOPT_POSTFIELDS are
left out (#1652): raw under unsafe until the pairing is modeled.
curl_easy_perform presents its CURLcode (`ok` projects a producer or a
copied-back length, not a plain operation). Threads are not granted (the
manual spells `send` but not drop-any-thread). Fixtures: the UAT surface
plus every case kind against the host library without a transfer; an
unlisted option refused with the case to add; the version view invalidated
by curl_global_cleanup; handles cleaned up once under the debug allocator.

* Release UAT: libcurl_main.w rewritten to the facade surface, 8 `unsafe` to 0 (ruling §66); the release UAT copies lib/facades/libcurl.w into the project as the other three do

Same observable output ("libcurl UAT passed"): global init, an Easy handle
scoped to configure_handle so it is cleaned up before curl_global_cleanup,
CURLOPT_NOSIGNAL through the variadic contract, the version number read
through the borrowed record's scalar field, the version text through
curl_version().

* main.w: run_cli copies the source path instead of field-moving it — the pinned seed carries the 16-bit field-path bug (#1631) that #1656 fixes, and must still compile this tree; retire with the next seed cut

---------

Co-authored-by: Eric Hartford <[email protected]>
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.

1 participant