Skip to content

Design and implement type alias feature (type MyType = ...) #166

Closed

Description

@LunaStev

Background:

Wave currently requires developers to explicitly repeat complex type definitions in full.
This makes code harder to maintain and reduces readability, especially when using deeply nested pointer types, tuples, or array types.

A type alias feature would allow defining shorthand names for types, improving clarity and reusability without affecting runtime behavior.

Expected Behavior:

Introduce a new declaration syntax for type aliases:

type MyInt = i32;
type Point = tuple<i32, i32>;
type Ptr10 = ptr<ptr<ptr<ptr<ptr<ptr<ptr<ptr<ptr<ptr<i32>>>>>>>>>>;
  • Aliases are fully expanded at compile time with no runtime overhead.

  • Type-checking uses the resolved underlying type — aliases are not treated as distinct types.

  • Nested and chained aliases are allowed:

type A = B;  
type B = i64;
  • Recursive aliases are disallowed:
type A = ptr<A>;  // ❌ invalid

User Scenarios:

  1. A developer creates a reusable alias for a 10-layer pointer type: type Ptr10 = ptr<...>;
  2. A team defines a standard alias type FileId = i32; for shared meaning across files.
  3. Code becomes easier to maintain by using type Vector3 = tuple<f32, f32, f32>; rather than rewriting it.

Additional Information:

  • Language version: - (not yet assigned)

  • Target branch: develop

  • Parser: Add support for parsing type IDENT = TYPE; syntax

  • AST: Introduce TypeAliasNode or equivalent

  • IR Generator: Substitute type alias with the underlying resolved type during code generation

  • Validation: Must prevent infinite recursive aliasing

Activity

  1. self-assigned this
    on May 30, 2025
  2. added
    enhancement
    feature request
    on May 30, 2025
  3. moved this to Backlog in Waveon Jun 2, 2025
  4. LunaStev commented on Aug 3, 2026

    @LunaStev
    MemberAuthor

    Base type alias syntax and lowering are implemented. Recursive alias rejection remains tracked separately in #167, so this feature issue is complete.

  5. moved this from Backlog to Done in Waveon Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions