Skip to content

Define async completion, cancellation, and frame lifetime semantics #440

Open

Description

@LunaStev

Parent: #439

Problem

Wave needs an explicit semantic contract before parser, runtime, and backend implementations choose incompatible behavior. The contract must fit Wave's general-purpose, low-level model without importing Rust ownership rules or an LLVM coroutine ABI.

Scope

  • Define the source meaning of async fun name(...) -> T and await expression.
  • Decide the concrete frontend representation of an asynchronous result, including whether users spell a built-in Future<T> type directly.
  • Define completion, pending, failure, cancellation, and executor-shutdown behavior.
  • Define which locals live in the suspended frame and when frame storage is released.
  • State that raw pointers retained across an await keep Wave's existing programmer-managed validity contract.
  • Decide private async fun main() behavior and executor ownership.
  • Reject async extern, export, constructors, and other unsupported declaration forms with diagnostics until their ABI exists.
  • Specify how async functions interact with generics, variants, recursion, and imports.

Completion criteria

  • A concise normative contract covers call, suspension, resumption, completion, and cancellation.
  • Surface examples and invalid examples are agreed.
  • No rule introduces let, a borrow checker, or mandatory unsafe blocks.
  • LLVM and Whale can implement the contract without exposing backend-specific frame layout.
  • Follow-up syntax, HIR, lowering, runtime, and std issues reference the decisions.

This is a design issue; implementation belongs in the focused child issues.

Implementation audit — 2026-09-23

Implemented behavior is visible in async_frontend tests, front/parser/src/async_lower.rs and std/task.wave: Future, lazy calls, await states, cancellation and explicit executor shutdown. Ordinary main remains the entry point and private async main is currently rejected. This design tracker remains open until its remaining decisions and child-issue links are reconciled; no new language specification document was introduced by this audit.

Activity

  1. added
    enhancement
    feature request
    discussion
    on Aug 30, 2026
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

    discussionenhancementfeature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions