-
Notifications
You must be signed in to change notification settings - Fork 790
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
Remove one "impossible" error #5746
Conversation
| Item.ExnCase tcref -> | ||
error(Error(FSComp.SR.tcExceptionConstructorDoesNotHaveFieldWithGivenName(tcref.DisplayName, id.idText), id.idRange)) | ||
| _ -> | ||
error(Error(FSComp.SR.tcConstructorDoesNotHaveFieldWithGivenName(id.idText), id.idRange)) |
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.
But this case is impossible, correct? Shouldn't we report this somehow?
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.
"impossible"
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.
What I mean is that item
is matched some lines above to be one of the two cases and item
is immutable? This case means someone has changed something and missed to do some work. Removing failwith
means the mistake will be spotted later (or not at all)
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.
actually that is what already happend. the case was added and nobody changed the failwith "impossible"
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.
But line above reads | (Item.UnionCase _ | Item.ExnCase _) as item ->
how can this match another case?
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.
it does not today. wait until someone adds the active pattern part ;-)
| Item.ActivePatternResult(_,_,_,_) -> | ||
error(Error(FSComp.SR.tcActivePatternsDoNotHaveFields(), id.idRange)) | ||
| _ -> | ||
error(Error(FSComp.SR.tcConstructorDoesNotHaveFieldWithGivenName(id.idText), id.idRange)) |
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.
Should we still report that this error message might need to be refined (in case it happens)? Would this be an advantage of failwith "impossible"
here?
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.
failwith "impossible" is arguably the worst you can do
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.
Yes ideally the code would be written in a way to not compile when written incorrectly, but if that cannot be achieved imho throwing is better than doing/reporting potentially incorrect 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.
Actually I think even having a confusing error message is better than what existed. The current state of the world (without @forki's changes) paints the whole editor red if you use the incorrect code:
These internal errors are critical to root out given this, since it's pretty much undiagnosable where the user error is.
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 but imho we still should make sure the error message indicates this is not implemented and something which needs to be fixed if it occurs.
Otherwise users get wrong messages on their code which is arguably worse than a compiler crash
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 don't give a wrong message. We just give a very generic one
423564f
to
89e498b
Compare
@KevinRansom is something wrong with master? the error for linux build seems unrelated |
@forki not that I know. The error is:
At this point I believe the script is running the built compiler, so I suppose there is some possibility they are related. |
@KevinRansom #5733 also has this error but with no compiler, so something's wrong in the linux build |
@cartermp indeed it does. |
it's noew green after rebase |
fixes #5745