Skip to content

Disallow recursive type aliases (e.g., type A = ptr<A>) #167

@LunaStev

Description

@LunaStev

Background:

Wave is planning to support the type alias feature, which allows assigning names to existing types.
While chained aliases like type A = B; type B = C; are valid, recursive aliases such as type A = ptr<A>; must be disallowed to prevent infinite loops during type resolution.

This feature is planned but not yet implemented, and this issue addresses a specific validation rule that will be needed once the alias system is added.

Task:

Define logic to detect and reject self-referential type aliases — both direct and indirect.

Example:

type A = ptr<A>;      // ❌ invalid
type B = C;
type C = B;           // ❌ invalid (indirect recursion)

The compiler should raise an error like:

Error: Recursive type alias detected: 'A' references itself

Expected Behavior:

  • Reject recursive type aliases
  • Allow valid nested alias chains
  • Provide helpful diagnostics

Difficulty:

🟢 Easy – Suitable for contributors with basic understanding of type checking or dependency resolution

Metadata

Metadata

Assignees

Labels

enhancementA request for a new feature or improvement.good first issueIssues that are good for newcomers or first-time contributors.

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions