Skip to content

Implement Wave variant types and exhaustive variant matching #347

Open

Description

@LunaStev

Roadmap context

This tracks the payload-bearing variant type planned for Wave after the current enum and module contracts. Existing enum remains an integer constant set and must not be reinterpreted.

Language contract

variant Result<T, E> {
    Ok(T),
    Err(E)
}

match result {
    Result::Ok(value) => { use_value(value); }
    Result::Err(error) => { handle_error(error); }
}

Scope

  • A distinct variant token, AST node, and type representation.
  • Payload-free, single-payload, and multiple-payload cases.
  • Generic variant construction and type checking.
  • Infinite-size recursion rejection while pointer recursion remains valid.
  • Variant patterns, arm-local bindings, nested patterns, and exhaustiveness.
  • Control-flow analysis for exhaustive matches.
  • Module visibility and private/public lookup.
  • Backend layout and code generation without changing existing enum behavior.

Required diagnostics

Duplicate cases, unknown cases, payload arity/type mismatch, unresolved generics, infinite-size recursion, duplicate patterns, non-exhaustive matches, unreachable wildcard arms, and unsupported ABI exposure.

Completion criteria

  • Generic Result<T, E> and Option<T> work end to end.
  • Existing integer/const/enum match behavior does not regress.
  • Variant values cannot cross a C ABI boundary without an explicit supported contract.
  • Parser, semantic, codegen, and execution regressions cover valid and invalid programs.

Small parser and validation pieces may be filed separately as good first issues.

Activity

  1. added
    enhancement
    help wanted
    feature request
    on Aug 25, 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

    enhancementfeature requesthelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions