Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP Code Action: Convert inexhaustive let to case #3868

Open
GearsDatapacks opened this issue Nov 21, 2024 · 2 comments · May be fixed by #3875
Open

LSP Code Action: Convert inexhaustive let to case #3868

GearsDatapacks opened this issue Nov 21, 2024 · 2 comments · May be fixed by #3875

Comments

@GearsDatapacks
Copy link
Member

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.

@giacomocavalieri
Copy link
Member

I love the idea!

@GearsDatapacks
Copy link
Member Author

I can work on this. It should be pretty trivial to adapt the existing code action to work in this case too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants