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
Update pattern matching error message. #5007
Conversation
Excellent, the message has always been tricky to understand. |
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 like this change a lot.
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.
We have no tests?
@isaacabraham I'll take care of the errors. |
@@ -178,7 +178,7 @@ type internal SR private() = | |||
/// All branches of an 'if' expression must have the same type. This expression was expected to have type '%s', but here has type '%s'. | |||
/// (Originally from ../FSComp.txt:24) | |||
static member elseBranchHasWrongType(a0 : System.String, a1 : System.String) = (GetStringFunc("elseBranchHasWrongType",",,,%s,,,%s,,,") a0 a1) | |||
/// All branches of a pattern match expression must have the same type. This expression was expected to have type '%s', but here has type '%s'. | |||
/// All branches of a pattern match expression must return values of the same type. The first branch returned a value of type '%s', but this branch returned a value of type '%s'. |
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.
shouldn't it still be return expressions
and returned an expression
?
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.
Hmmmm. I'm not sure :-)
@KevinRansom I'm not sure what the error is anyway - can you explain for future reference? Thanks! |
The error is:
The fix is to run :
|
@isaacabraham The expected text needs updating
|
@dotnet-bot test Ubuntu16.04 Release_default Build please |
Thank you. |
Thank you for fixing the tests. Next time I'll check that stuff myself, now that I know what's needed! |
Thank for the PR. |
This is a small change that (IMO) improves the error message displayed when different branches of a pattern match return values of different types.
Before
All branches of a pattern match expression must have the same type. This expression was expected to have type 'string', but here has type 'int'.
After
All branches of a pattern match expression must return values of the same type. The first branch returned a value of type 'string', but this branch returned a value of type 'int'."