Repository navigation
Modeled C D66: discriminated variadic contracts, borrowed record views, and safe libcurl UAT - #1661
Merged
Merged
Conversation
Contributor
Author
|
Facade fixture sweep with this branch's seed-built stage1 (
Battery ( |
added 5 commits
September 24, 2026 19:17
…cade'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).
…ted 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.
…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.
…e` 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().
ehartford
force-pushed
the
modeled-c-d66-curl
branch
from
September 24, 2026 23:18
02af8e3 to
0085bfe
Compare
This was referenced Sep 25, 2026
ehartford
marked this pull request as ready for review
September 25, 2026 01:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements D66 discriminated variadic contracts and borrowed record views, adds
lib/facades/libcurl.wagainst the real curl header, and rewrites the libcurl release UAT under that ruling from eightunsafeblocks to zero.Variadic clauses require a compile-time selector and explicitly listed integer or string cases. Sema selects the case and MIR materializes that decision; the generated bridge preserves the C variadic ABI. String cases use a call-scoped NUL-terminated temporary. Unlisted, runtime, pointer, and callback cases without the necessary contracts fail with diagnostics.
Borrowed record returns become
Option[&T], with parameter or domain origins propagated through existing lifetime and invalidation checks. Pointer fields remain raw until field-level contracts are defined; static record returns remain rejected.typedef void His translated as ac_voidalias so opaque C handles match their resource representation.The libcurl facade models Easy ownership, nine setopt cases, borrowed version records, and static version/error strings. Callback and retained variadic options remain tracked in #1652. The four release UAT fixtures contain no
unsafe; the full user-programs-safe gate is still red on the recovered tally example, pending free-function callbacks (#1644) and element-count buffers (#1643). This PR does not rewrite that example to bypass the gate.Part 2 of the GitHub stack: #1656 → #1661 → #1662. The field-path record fix belongs to #1656. This layer retains one marked copy of
actual_options.output_pathso the pinned seed can compile the stack; remove it after a seed cut containing #1656.Iterate verification passed the D66/libcurl behavior, compile-error, and allocator fixtures, resolution audits, specification inventory, and the libcurl UAT. The corrected stack at 974c8ba passed the full seed-driven build, fixpoint (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; its final verdict table is posted there.
Other findings remain tracked: #1653 header translation, #1654 build input freshness, and #1655 view invalidation on returning branches.