-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add an error message for "invalid unapply return type" error. #3501
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
Add an error message for "invalid unapply return type" error. #3501
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Added" instead of "Add")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
I thought I already fixed this. It looks like the dotty-bot hasn't been rebuilt since then 😟 |
b7cab0f
to
0a1bb70
Compare
I fixed the commit message =) |
@markarasev This new feature is called Name Based Pattern. Please note there there is also a Product Pattern. |
a9b0243
to
776f25b
Compare
@senia-psm I updated the explanation to cover these cases. |
@@ -113,6 +113,7 @@ | |||
IllegalStartOfStatementID, | |||
TraitIsExpectedID, | |||
TraitRedefinedFinalMethodFromAnyRefID, | |||
InvalidUnapplyReturnTypeID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or UnapplyInvalidReturnTypeID
? I am now struggling with the name for the other one from Applications.scala
, and I tend to think that UnapplyInvalidNumberOfArgumentsID
sounds better than InvalidUnapplyNumberOfArgumentsID
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for me, I updated the names.
@@ -92,7 +93,7 @@ object Applications { | |||
def getTp = extractorMemberType(unapplyResult, nme.get, pos) | |||
|
|||
def fail = { | |||
ctx.error(i"$unapplyResult is not a valid result type of an $unapplyName method of an extractor", pos) | |||
ctx.error(InvalidUnapplyReturnType(unapplyResult, unapplyName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the pos
being passed here? (sorry for the probably naive question, I am just starting on those error messages)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually misunderstood this value's usage, fixed this.
c09b33d
to
0240bf7
Compare
In Dotty, Product subclasses are also legal unapply result types. So this specific PR is invalid. It would be good to
|
@odersky do you mean that this part of the explanation is not explicit enough about Product subclasses?
By "changes section in the references" do you mean these docs http://dotty.epfl.ch/docs/reference/changed/pattern-matching.html ? They seem to be up to date. For your last point, do you mean I should add more unit tests? |
@OlivierBlanvillain This has been inactive for a year. Let's merge or close this now. |
0240bf7
to
2ea1d87
Compare
Part of #1589.