Skip to content

feat: implicit enum selector (.VARIANT) syntax awareness #11

Description

@SchoolyB

Summary

Grayscale supports implicit enum selectors (STANDARD.md §3.2.4) — the shorthand .VARIANT instead of EnumName.VARIANT when the expected enum type is known from context. The LSP has no awareness of this syntax.

Example

mut dir Direction = .NORTH

dir = .SOUTH

when dir {
    is .NORTH { println("north") }
    is .SOUTH { println("south") }
    default { println("other") }
}

if dir == .WEST { println("west") }

do get_dir() -> Direction { return .NORTH }

mut c = Config{ dir: .EAST }

Scope

  • Recognize .VARIANT as valid syntax (no false diagnostics)
  • Ideally provide completion for enum variants when a dot is typed in a context where an enum type is expected
  • Awareness in when/is branches, assignments, function arguments, return statements, struct literal fields, and comparisons

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