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

List pattern matching #3108

Open
giacomocavalieri opened this issue May 7, 2024 · 6 comments
Open

List pattern matching #3108

giacomocavalieri opened this issue May 7, 2024 · 6 comments
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium

Comments

@giacomocavalieri
Copy link
Member

There's a strange pattern that I don't think should compile when pattern matching on a list:

case list {
  [first..rest] -> todo
//^^^^^^^^^^^^^ This compiles as [first, ..rest]
  _ -> todo
}

I think it should be a parse error instead

@giacomocavalieri giacomocavalieri added the bug Something isn't working label May 7, 2024
@zanddev
Copy link

zanddev commented May 7, 2024

@giacomocavalieri This is a duplicate of #3107, but this issue is written better than mine.

@lpil
Copy link
Member

lpil commented May 7, 2024

It would be a breaking change to make this an error, but we could emit a warning.

@lpil lpil added help wanted Contributions encouraged good first issue Good for newcomers priority:medium and removed bug Something isn't working labels May 7, 2024
@giacomocavalieri
Copy link
Member Author

Oh right that's unfortunate, I'll work on adding the warning then!

@lpil
Copy link
Member

lpil commented May 7, 2024

Thank you

@giacomocavalieri
Copy link
Member Author

I was wondering, what would the warning say? Does it even make sense to have a warning to suggest a different way of writing it even if the formatter already takes care of it?

Something like this, maybe?

  [a..b]
  ^^^^^^

This is the same as writing `[a, ..b]`

@lpil
Copy link
Member

lpil commented May 21, 2024

Maybe we could say that the syntax is deprecated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:medium
Projects
None yet
Development

No branches or pull requests

3 participants