-
Notifications
You must be signed in to change notification settings - Fork 833
Remove one "impossible" error #5746
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5316,12 +5316,14 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p | |
| for (id, pat) in pairs do | ||
| match argNames |> List.tryFindIndex (fun id2 -> id.idText = id2.idText) with | ||
| | None -> | ||
| let caseName = | ||
| match item with | ||
| | Item.UnionCase(uci, _) -> uci.Name | ||
| | Item.ExnCase tcref -> tcref.DisplayName | ||
| | _ -> failwith "impossible" | ||
| error(Error(FSComp.SR.tcUnionCaseConstructorDoesNotHaveFieldWithGivenName(caseName, id.idText), id.idRange)) | ||
| match item with | ||
| | Item.UnionCase(uci, _) -> | ||
| error(Error(FSComp.SR.tcUnionCaseConstructorDoesNotHaveFieldWithGivenName(uci.Name, id.idText), id.idRange)) | ||
| | Item.ExnCase tcref -> | ||
| error(Error(FSComp.SR.tcExceptionConstructorDoesNotHaveFieldWithGivenName(tcref.DisplayName, id.idText), id.idRange)) | ||
| | _ -> | ||
| error(Error(FSComp.SR.tcConstructorDoesNotHaveFieldWithGivenName(id.idText), id.idRange)) | ||
|
|
||
| | Some idx -> | ||
| match box result.[idx] with | ||
| | null -> | ||
|
|
@@ -8644,13 +8646,16 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del | |
| assert (isNull(box fittedArgs.[currentIndex])) | ||
| fittedArgs.[currentIndex] <- List.item currentIndex args // grab original argument, not item from the list of named parameters | ||
| currentIndex <- currentIndex + 1 | ||
| else | ||
| let caseName = | ||
| match item with | ||
| | Item.UnionCase(uci, _) -> uci.Name | ||
| | Item.ExnCase tcref -> tcref.DisplayName | ||
| | _ -> failwith "impossible" | ||
| error(Error(FSComp.SR.tcUnionCaseConstructorDoesNotHaveFieldWithGivenName(caseName, id.idText), id.idRange)) | ||
| else | ||
| match item with | ||
| | Item.UnionCase(uci, _) -> | ||
| error(Error(FSComp.SR.tcUnionCaseConstructorDoesNotHaveFieldWithGivenName(uci.Name, id.idText), id.idRange)) | ||
| | Item.ExnCase tcref -> | ||
| error(Error(FSComp.SR.tcExceptionConstructorDoesNotHaveFieldWithGivenName(tcref.DisplayName, id.idText), id.idRange)) | ||
| | Item.ActivePatternResult(_,_,_,_) -> | ||
| error(Error(FSComp.SR.tcActivePatternsDoNotHaveFields(), id.idRange)) | ||
| | _ -> | ||
| error(Error(FSComp.SR.tcConstructorDoesNotHaveFieldWithGivenName(id.idText), id.idRange)) | ||
|
||
|
|
||
| assert (Seq.forall (box >> ((<>) null) ) fittedArgs) | ||
| List.ofArray fittedArgs | ||
|
|
||

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
itemis matched some lines above to be one of the two cases anditemis immutable? This case means someone has changed something and missed to do some work. Removingfailwithmeans 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 ;-)