Skip to content

Parse async functions and await expressions #441

Closed

Description

@LunaStev

Parent: #439

Summary

Add source-level async and await syntax without performing coroutine lowering.

Scope

  • Reserve async and await in the lexer with stable token names and spans.
  • Parse async fun name(...) -> T { ... } wherever an ordinary function declaration is valid.
  • Parse prefix await expression with documented precedence.
  • Preserve async declarations and await expressions in the source AST.
  • Support visibility parsing as pub async fun; continue rejecting every public main declaration.
  • Produce focused diagnostics for missing fun, missing await operand, invalid declaration order, and malformed bodies.
  • Keep extern and export async forms syntactically representable only if needed for a precise semantic rejection; do not silently accept them as synchronous functions.

Completion criteria

  • Lexer and parser unit tests cover valid nested expressions and malformed syntax.
  • AST debug output exposes async declarations and await nodes.
  • Existing identifiers and declaration parsing regressions remain green apart from the intentional keyword reservation.
  • Parser changes do not add LLVM or runtime dependencies.

Semantic legality and types are handled separately from this issue.

Implementation audit — 2026-09-23

Verified the lexer/parser/AST implementation and reran async_frontend with the complete parser and frontend test suites. Async flags, await result types/spans and malformed forms are covered. Private async main is deliberately rejected until its executor entry contract is provided; ordinary main remains supported. This closes the syntax task, not the runtime parent #439.

Activity

  1. added
    enhancement
    feature request
    needs testing
    on Aug 30, 2026
  2. LunaStev commented on Sep 23, 2026

    @LunaStev
    MemberAuthor

    Verified the lexer/parser/AST implementation and reran async_frontend with the complete parser and frontend test suites. Async flags, await result types/spans and malformed forms are covered. Private async main is deliberately rejected until its executor entry contract is provided; ordinary main remains supported. This closes the syntax task, not the runtime parent #439.

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

    enhancementfeature requestneeds testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions