Skip to content

§31.8.6: the drafter's contradiction check misses a function that assigns the destroyer global only through a function it calls #3338

Closed

Description

@ehartford

The drafter records a function that assigns a global in its own body (contract-proofs.txt, F<TAB>assigns<TAB>G<TAB>proof; CImport.ci_body_call_evidence_walk emits assign:<name>, CiProjectSymbol.assigned_globals), and a contract that describes such a function contradicts the destroyer clause that names the global (SemaFacade.check_facade_assigner_proofs).

Not covered: a function that assigns the global only through a call.

void (*node_release)(Node *n) = plain_release;
void set_release(void (*f)(Node *n)) { node_release = f; }   /* recorded */
void node_configure(void) { set_release(other_release); }     /* not recorded */

A contract with drop node_release that describes node_configure is accepted. §31.8.6 says a function that assigns the global stays raw, and the in-unit check (verify_facade_hook_assigners) already follows calls ("a function that calls an assigner assigns"); the drafter's proof should too.

Fix: close assigned_globals over the project's direct calls before facade_proofs writes the lines (the proof text names the path: "calls set_release, whose body assigns node_release"). A call through a function-pointer field or to a function no unit defines stops the walk, as it does for the other proofs (weaker than a grant, §31.7).

Test: extend test/internals/conan_contract_proofs_assigns_test.w with node_configure.

The §31.8.6 mark names this limit; it goes when this lands.

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