Skip to content

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

@LunaStev

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

Metadata

Metadata

Assignees

Labels

enhancementA request for a new feature or improvement.feature requestA request for a new feature or functionality.

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions