Skip to content

Facade grammar: a producer taking an optional parent (curl_mime_init(easy), NULL allowed since 7.87.0) is presented on the parent and collides with its new #3122

Done

Description

@ehartford

Part of #3115; gap 4 of #3111.

curl_mime_init(CURL *easy) is presented as a method of Easy and collides with Easy.new ("function 'Easy.new' is already defined") even with rename new on the mime producer; param easy fixed null then hits the "a resource is passed by the value that owns it" refusal (the NULL-on-create issue). curl_mime_init(3): since 7.87.0 the easy handle may be NULL and the mime depends on no easy handle.

Need: (a) a rename on a producer names the produced resource's constructor (Mime.new), never the parameter's type; (b) an optional parent parameter, presented as absent or Option[&Easy], with independent stating no lifetime tie when absent.

Done when: Mime.new() presents, no collision; fixture.

Activity

  1. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Reproduced on main 26eb17e with a 9-line header (two resources, curl_mime_init(easy *) a producer of the second).

    What happens. A producer whose first parameter receives a resource is presented as a method of that resource (db.prepare() → Statement), so curl_mime_init is easy.mime_init(). rename new on it renames that method, giving a second Easy.new: 'function Easy.new is already defined'. That part is the rule working as written, not a bug.

    A bug beside it: with analyze … contract prints producer: curl_mime_init -> Mime.new for the same contract, while the rendering puts it on Easy. The view names the wrong host. That is mine to fix and needs no ruling.

    Needs Eric (presentation rules, §16.2b.4 and §16.2b.11):

    1. Should rename on a producer be able to move it to the produced resource (Mime.new(e)), or should there be a spelling that says 'a constructor of the produced type, taking the parent as an argument'? Today the host is always the first parameter's resource.
    2. The optional parent: curl_mime_init(NULL) is legal since 7.87.0. A producer that takes Option[&Easy], with the result independent when it is absent, has no clause. param easy fixed null is refused ('a resource is passed by the value that owns it').

    Prediction: yes to a constructor on the produced type when the contract says so (the caller thinks 'make a Mime', not 'ask an Easy for one'), 65%; the optional parent as nullable param N on a producer with independent, 60%.

  2. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Correction to my comment above, after running both call forms on main 26eb17e: the contract view is right, and there is no view bug.

    A producer whose first parameter receives a resource is presented twice: as a constructor of the produced type (Mime.curl_mime_init(e)) and as a method of the parameter's resource (e.curl_mime_init()). Both compile and run (they print the same value in my 9-line fixture). rename new renames both, and the second lands on Easy.new, which is the collision.

    So question 1 for Eric is sharper than I wrote it: when a producer is renamed, should the rename apply to the constructor only (Mime.new(e)), with the method on the parent keeping its C-derived name or going away? The two presentations of one function are also worth a look in their own right: one meaning, two spellings.

  3. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Ruled, 2026-11-18 (D214): one home chosen by of (no of: a method of the first resource received; of Mime: a constructor of the produced type, no forwarder); an absent parent is a second constructor (Mime.new() beside Mime.with(e)), stated with param N fixed null as a cited claim that may carry a version floor; two entries for one C name, each with its own rename, settled in the same change. Count the call sites of the spelling that goes away first; its error offers the surviving one.

  4. ehartford commented on Nov 24, 2026

    @ehartford
    ContributorAuthor

    State against the ruling (D214), measured on main 21ec8b4 with a 7-line header (easy, mime, mime_init(easy *)):

    Done: one home chosen by of (SemaFacade.with:57, FacadeRender.with:1245, SemaCheck.with:38859; §16.2b.4 has the words).

    Not done, two parts:

    1. param N fixed null on a resource parameter. Still refused at SemaFacade.with:2262 ("receives a modeled resource; a resource is passed by the value that owns it, never fixed"). The ruled meaning: on a producer, it makes a constructor of the produced type with no parent, and the value it returns depends on nothing.
    2. Two entries for one C name. collect_facade_fn (SemaFacade.with:1446) refuses a second fn item for the same function in one facade, and its help text already promises what the ruling asks ("give each item its own 'rename'"). The model underneath is one contract per C function (foreign_contract_index: fn sym -> index, read in 283 places in SemaFacade.with), so the second entry needs an operation identity of (function, which parameters are fixed), in the collector, the verifier, the renderer and the call-site lookup.

    One thing in the ruling's example that cannot be written today: Mime.with(e). rename with fails to parse because with is a reserved word ("expected identifier"). Either the example takes another name (Mime.from(e), Mime.of(e)), or a method name after rename may be a keyword as a member name after . already may. That is a wording point for the spec diff, not a blocker.

    Still to settle in the same change (the ruling says so): the spelling of the version floor on the claim ("holds since 7.87.0"), and the refusal against an older pinned package.

    This is mine to implement; it is ruled. Fixture for the done-when: the header above, Mime.new() beside the parented constructor, no collision with Easy.new.

  5. ehartford commented on Nov 24, 2026

    @ehartford
    ContributorAuthor

    Part 1 of D214 is merged (#3588): on a producer, param N fixed null on its resource parameter is the absent parent. Mime.new() presents on the produced type, does not collide with the parent's new, and its value depends on nothing. Fixture: behav_d214_producer_with_absent_parent.

    Proposed words for §16.2b.11, for Eric to bless or replace (not landed):

    On a producer, param N fixed null may name a parameter that receives a resource. It states that the function accepts no parent there: the constructor takes none, and the value it returns depends on nothing through that parameter. That NULL is accepted is the contract's claim. On every other operation a parameter that receives a resource is passed by the value that owns it and cannot be fixed.

    Left for this issue (the rest of D214):

    1. Two fn items for one C function, so Mime.new() and the parented constructor can both exist. Today a facade may describe mime_init once, so a contract chooses one of the two.
    2. The version floor on the claim ("holds since 7.87.0") and the refusal against an older pinned package.
    3. The ruling's example name Mime.with(e) cannot be written: with is a reserved word after rename.
  6. ehartford commented on Nov 24, 2026

    @ehartford
    ContributorAuthor

    Further on part 2 (two fn items for one C function), measured on a local branch on top of #3588:

    • Two items with distinct renames already work in general (ruling Amendment 3: each later item gets its own declaration linked to the same C symbol, facade_render_presentation_aliases). What was missing for a producer: the second presentation was treated as an operation on the parent, not as a producer. With the resource's from clause repeated for the presentation's declaration (one function in the renderer, written and building locally), the contract below is accepted and renders type Mime ephemeral { parent: Option[&Easy], … } with both constructors:
    fn mime_init
        of Mime
        rename from_easy
    fn mime_init
        rename new
        param 0 fixed null
    
    • What still refuses the program is the checker, not the facade. Mime.from_easy(e).unwrap() is accepted. Mime.new().unwrap() is refused: bound directly, "binds a view into a temporary Option[Mime]"; bound first and returned, "returned ephemeral value may outlive its origin 'made'", with the note that Mime depends on Easy. The type is a view-carrying type as soon as one constructor has a parent, and the origin rules then treat every value of it as borrowed from something, including the one whose parent slot is None.

    That is the point the ruling makes ("dependency belongs to a value's origin, not to its type") and the piece it names under Alternatives as needing origin analysis. The work left is in SemaCheck (the view-producer and returned-ephemeral rules), not in the facade: a value of an ephemeral type that no argument could have given an origin has none.

    So today a contract can state either constructor (the absent-parent one alone is merged and usable); both together wait on that checker change. The facade half is a local commit and will land with it.

  7. ehartford commented on Nov 24, 2026

    @ehartford
    ContributorAuthor

    Both constructors now work together (#3589): Mime.from_easy(e) tied to its parent and Mime.new() free, for one C function. Fixtures: behav_d214_both_constructors, err_d214_parented_value_outlives_parent.

    One thing in that PR is wider than facades and is flagged here for Eric's veto: the checker no longer reads the by-value result of a builtin that consumes its receiver (unwrap, expect, … on an Option or Result held by value) as a view of that receiver. It carries the receiver's origins instead. It is what the ruling's "dependency belongs to a value's origin, not to its type" needs, and the refusals for a reference result or a borrowed receiver are unchanged.

    What is left on this issue, all three for Eric:

    1. Bless or replace the proposed §16.2b.11 words (above), plus one sentence that a second presentation of a producer is a producer.
    2. The version floor on the claim ("holds since 7.87.0") and its spelling.
    3. The example name Mime.with(e): with cannot follow rename.

    Labelling human attn needed for those.

  8. ehartford commented on Nov 25, 2026

    @ehartford
    ContributorAuthor

    Ruled by Eric, 2026-11-25 (answers to briefs.md).

    Label removed; the words, the since suffix with its refusal against an older pinned package, and the keyword after rename are mine.

  9. ehartford commented on Nov 25, 2026

    @ehartford
    ContributorAuthor

    Implemented, in the PR that follows this comment: param N fixed L since V with its refusal against an older pinned release, and a keyword after rename.

    Two sentences for §16.2b.11, for Eric to bless or replace (not landed):

    A param N fixed clause may end with since V, the release of the package from which the claim holds. A project that pins an earlier release of that package is refused.

    The name after rename is a member name and may be a keyword.

  10. ehartford commented on Nov 26, 2026

    @ehartford
    ContributorAuthor

    Ruled by Eric, 2026-11-25 (third answer): yes to sentence 2 as written; the docs PR waits on two fixes to since V.

    1. Comparison. Dotted numeric parts compare numerically (a missing part is 0); a trailing ASCII letter suffix orders after the base release, in order (1.1.1 < 1.1.1a < 1.1.1w); a -prerelease suffix orders before the bare release (3.0.0-beta2 < 3.0.0). A release string that does not fit that format is refused, never silently trimmed. Tests for OpenSSL-style and prerelease releases.
    2. No pinned release: fail closed. A since V claim on a package with no pinned release is refused. Test.
    3. "Only fixed takes it" stays out of the spec.

    Then the docs PR lands sentence 2 as written and sentence 1 as:

    A param N fixed clause may end with since V, the release of the package from which the claim holds. Releases compare by dotted numeric parts (missing parts as 0), with trailing letter suffixes ordered after the base release and -prerelease suffixes ordered before it. A project that pins an earlier release—or pins no release—of that package is refused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions