Skip to content

Enum variant shorthand in generic arguments fails inside non-void helper functions #36

Closed

Description

@ehartford

Current behavior

Enum variant shorthand in a generic argument position can work in main, but fail in ordinary helper functions that return a value.

Minimal repro:

type D =
    | X
    | Y

fn make_vec -> Vec[D]:
    let xs: Vec[D] = Vec.new()
    xs.push(.X)
    xs

fn main:
    let _ = make_vec()

with check fails with:

error: enum variant shorthand does not match expected enum type
 --> test.w:7:13
7 |     xs.push(.X)
  |             ^^

Control cases

These both work:

  1. Qualified syntax inside the helper:
fn make_vec -> Vec[D]:
    let xs: Vec[D] = Vec.new()
    xs.push(D.X)
    xs
  1. The shorthand form inside main:
fn main:
    let xs: Vec[D] = Vec.new()
    xs.push(.X)

So the issue is not Vec.push or enums in general. It is the type inference/lowering for shorthand enum variants inside non-void helper functions.

Expected behavior

.X should compile anywhere the expected type is known, including inside helpers that return a value.

Why this matters

This currently blocks builders/helpers that accumulate enum-typed values and then return a composite result.

Activity

  1. added
    bug
    error-messages
    on Mar 22, 2026
  2. added a commit that references this issue on Jun 8, 2026
    f83be73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugerror-messages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions