Skip to content

LSP Code Action: Convert inexhaustive let to case #3868

Closed
@GearsDatapacks

Description

@GearsDatapacks

For example, you have this code:

pub type Wibble {
  Wibble(wibble: Int)
}

pub fn main(wibble: Wibble) {
  let Wibble(inner) = wibble
  do_something_with(inner)
}

But then you change the Wibble type:

pub type Wibble {
  Wibble(wibble: Int)
  Wobble(wobble: Int)
}

The let expression now fails to compile. It could be useful to have a code action to turn:

let Wibble(inner) = wibble

into:

let inner = case wibble {
  Wibble(inner) -> inner
  _ -> todo
}

This would be very similar to the code action to convert let assert to case, except it would only be offered if the let expression is not exhaustive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions