Skip to content

ref should not be required for _ patterns in cases #950

Open
@peblair

Description

@peblair

Consider the following code:

type Foo = { x :: Number }

data Bar:
  | bar(ref y :: Foo)
end

a = bar({x: 2})

b = cases(Bar) a:
  | bar(_) => 2
end

This fails with the error "Cases on ref field needs to use ref", which can be fixed by changing the pattern in the cases expression to bar(ref _). This seems silly, since (unless I'm mistaken) using an underscore at this position means, "I don't care what this value is". As such, it seems silly to force users to explicitly annotate that they're ignoring a reference instead of ignoring a value.

Maybe I'm missing some semantic or pedagogical point here, but it seems strange.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions