Skip to content

A bare variant shorthand is not accepted under an Option demand in an assignment or an if-expression branch #3062

Closed

Description

@ehartford

§9.5 / D22: an Option[E] demand types a bare variant shorthand as Some(.V) (the census pattern some-at-option-demand counts the written Some(x) as ceremony). Two sites still require the Some:

enum Kind:
    A
    B
var k: Option[Kind] = None
k = .A                                   # error: type mismatch in assignment
k = if cond: .A else: .B                 # error: if expressions do not establish one compatible owned result type

Both are accepted written k = Some(.A) / k = Some(if cond: .A else: .B). Expected: the variable's type is the demand for the assigned expression and for both branches of the if.

Found 2026-11-07 in src/SemaFacade.w (the D194 stack converts FACADE_VARIADIC_* to an enum and classifies a case into an Option[FacadeVariadicKind]); the three Some(...) there are granted in build/ceremony-allowances.tsv against this issue and come out when it lands.

Activity

  1. added
    spec-gap
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 7, 2026
  3. ehartford commented on Nov 8, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by the time of 961cd90: the issue's two spellings check clean with the installed compiler at that commit.

    enum Kind:
        A
        B
    fn main:
        var k: Option[Kind] = None
        k = .A
        k = if k.is_some(): .A else: .B
        print(f"{k.is_some()}")
    

    with check exits 0 with no diagnostics. The three Some(...) in src/SemaFacade.w granted against this issue come out in the with fix-ceremony sweep (#3061), whose Some-under-Option pass removes them.

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

    spec-gap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions