Skip to content

Document irrefutable unapply in pattern matching #6490

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

Closed
smarter opened this issue May 10, 2019 · 1 comment · Fixed by #6850
Closed

Document irrefutable unapply in pattern matching #6490

smarter opened this issue May 10, 2019 · 1 comment · Fixed by #6850

Comments

@smarter
Copy link
Member

smarter commented May 10, 2019

Unapply that return Some[X] or true are statically known to always match, and the exhaustiveness checker uses this knowledge (see https://github.com/lampepfl/dotty/blob/494f9e6c2a397ab47a08d16d09d64c88c4a0ee82/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala#L285-L294). This should be documented in http://dotty.epfl.ch/docs/reference/changed-features/pattern-matching.html

@smarter
Copy link
Member Author

smarter commented May 10, 2019

See also the (incomplete) notion of an irrefutable pattern in the spec: https://www.scala-lang.org/files/archive/spec/2.12/08-pattern-matching.html#irrefutable-patterns

@liufengyun liufengyun self-assigned this May 14, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Jul 12, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Jul 15, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Jul 15, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Dec 13, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Dec 13, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants