You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Modeled C D66: variadic cases that pair a callback with its userdata option (case CURLOPT_WRITEFUNCTION: callback … userdata param CURLOPT_WRITEDATA) or retain the pointed-to data (case CURLOPT_POSTFIELDS: … retains by param 0) are refused, not modeled #1652
Spec §16.2b.5 "Discriminated variadic contracts" (D66) lists three case contracts beyond a scalar and a copied str:
a callback with its userdata pairing — case CURLOPT_WRITEFUNCTION: callback param 2 userdata param CURLOPT_WRITEDATA
a retained pointer where the docs say "not copied" — a str/pointer case stating retains … by param 0 (curl's CURLOPT_POSTFIELDS)
The compiler (PR for D66: variadic param N selected by param P: with scalar and str cases) refuses both spellings in the parser with a diagnostic naming this issue, and lib/facades/libcurl.w leaves CURLOPT_WRITEFUNCTION/CURLOPT_WRITEDATA/CURLOPT_POSTFIELDS out. Setting them goes through the raw curl_easy_setopt under unsafe.
What is missing, from the facade-language side (analysis while implementing):
The callback case has no type.callback param 2 userdata param CURLOPT_WRITEDATA names the variadic position (2) as the callback and the option that carries its userdata, but the callback's C signature is not in the header for a variadic slot (curl declares it as a separate typedef, curl_write_callback). D51's inference test forbids inferring it: a wrong callback type is unsafety. The case needs the type stated, e.g. case CURLOPT_WRITEFUNCTION: curl_write_callback userdata param CURLOPT_WRITEDATA — a spelling for Eric to bless, since the spec's example has none.
The pairing spans two calls.easy.setopt(CURLOPT_WRITEFUNCTION, cb) and easy.setopt(CURLOPT_WRITEDATA, &data) are two presented calls; the userdata's With type U is fixed by the second and the callback's void * parameter must be typed &U by the first. That is a typed slot on the resource (Easy keeps a U per option pair) rather than a per-call pairing (stage 9's callback param N userdata param M types both in one call). It also needs the retention machinery: the callback and the userdata are kept by the handle until it is destroyed or the option is overwritten (retains … by param 0), and the userdata's borrow must outlive the handle.
The retained case (CURLOPT_POSTFIELDS: "the data pointed to is NOT copied") is the same retention mechanism on a str/pointer case: the presented call must keep the caller's storage alive for the handle's life (§16.3c's retains rule: a str that would coerce to a call-scoped temporary is refused; the caller passes storage it keeps).
Until these land the facade is honest about it: the cases are absent, the raw function stays available under unsafe, and the compiler refuses the spellings loudly rather than rendering a plain value.
Activity
Facade D66: discriminated variadic contracts (`variadic param N selec…
lib/facades/libcurl.w: the libcurl facade against the real curl/curl.…
Modeled C D66: discriminated variadic contracts, borrowed record view…
spec: require explicit variadic callback types (D66, #1652) (#1671)
Modeled C: explicit element buffers and callback composition (#1643)
Modeled C: callback state contracts and checked dataflow foundation (#…
Modeled C: explicit element buffers and callback composition (withlan…
Modeled C: callback state contracts and checked dataflow foundation (#…
Modeled C: explicit element buffers and callback composition (#1643) (#…
Modeled C: callback state contracts and checked dataflow foundation (#…
Modeled C: callback state contracts and checked dataflow foundation (#…
spec: retained variadic pairs — abandon, setter status contract, reta…
Modeled C: callback state contracts and checked dataflow foundation (#…
Modeled C: retained variadic callback pairs — abandon path, setter st…
libcurl facade: the write callback pair and abandon curl_easy_reset; …
tests: retained variadic pair fixtures; docs: pair-state implementati…
spec: retained userdata's mode is its callable's capture view (§12.4)…
tests: contract views carry the per-operation callbacks row (§16.2b.9, …
Modeled C: retained variadic callback pairs — abandon, setter status …
Sema: a callable retained as callback userdata stays a live view whil…