Open Smaug123 opened 1 month ago
I think this probably has to do with :?
in patterns more generally, not just function
.
You can repro the same contradictory warnings with
open System
type Foo =
inherit IDisposable
let foo ((_ : Foo) & (:? IDisposable)) = ();;
let foo ((_ : Foo) & (:? IDisposable)) = ();;
----------------------^^^^^^^^^^^^^^
stdin(6,23): warning FS0067: This type test or downcast will always hold
let foo ((_ : Foo) & (:? IDisposable)) = ();;
---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^
stdin(6,10): warning FS0025: Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s).
These, on the other hand, trigger no warnings:
let blah () =
([] : Foo list)
|> Seq.iter (function (x : #IDisposable) -> ())
let blah () =
([] : Foo list)
|> Seq.iter (fun (x : #IDisposable) -> ())
Is your feature request related to a problem? Please describe.
This fails with a rather amusing combination of two errors:
function
: Incomplete pattern matches on this expression. For example, the value 'some-other-subtype
' may indicate a case not covered by the pattern(s).:? IDisposable
: This type test or downcast will always hold.The error messages are telling me that the match is incomplete and complete at the same time!
Describe the solution you'd like
Accept the definition. It's presumably semantically equivalent to:
Describe alternatives you've considered
Just don't do this. Users can always do an explicit type annotation, and the code is even shorter! The failure mode just amused me.
This is super low priority, of course.