Skip to content

Deferred: a once parameter annotation so a consuming closure can cross a bundle boundary (D63 §12.4 call-once) #1604

Closed

Description

@ehartford

D63 (§12.4 "The callable type"): "A consuming closure may only be handed to a callee that invokes it at most once. Within one compilation the compiler proves this from the callee's body. Across a bundle boundary (§3.4) a parameter may be invoked any number of times, so a consuming closure passed across a bundle is rejected until a once parameter annotation exists (deferred)."

Stack #1585's D63 layer implements the proof from the body (sig_param_invoke_many: a parameter invoked twice, or once inside a loop) and rejects a consuming closure argument to a callee whose declaration is a bundle interface (no body in this compilation) with:

error: this closure consumes its capture and may be invoked once, but `f` has no body in this compilation (a bundle boundary), so it may invoke its parameter any number of times (§12.4; a `once` parameter annotation is #1604)

Needed: the annotation's spelling (e.g. f: once fn() -> T), its place in the bundle interface (.wi) so the caller's compilation sees it, and the check that the bundle's own body honors it (invokes at most once). Same cross-bundle shape as -> &T in §3.4.

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