Skip to content

feat: tagged enum support (variants with data payloads) #5

Description

@SchoolyB

Summary

Grayscale supports tagged enums (STANDARD.md §3.2.4) — enum variants that carry associated data payloads. The LSP has no awareness of this feature.

Example

const Shape enum {
    Circle(float)
    Rect(float, float)
    Point
}

mut s Shape = Shape.Circle(3.14)

when shape {
    is Shape.Circle(radius) {
        println("Circle with radius ${radius}")
    }
    is Shape.Rect(w, h) {
        println("Rectangle ${w} x ${h}")
    }
    is Shape.Point {
        println("Just a point")
    }
}

Scope

  • Update hover docs for enum to mention tagged variants
  • Symbol scanner should recognize variant payloads in enum declarations
  • Awareness of destructuring patterns in when/is blocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions