You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe this is the expected behavior for the current preview version of C# 8.0. But it will almost certainly behave the way you suggested in the final version of C# 8.0, see dotnet/csharplang#2389.
Version Used:
Visual Studio Version 16.0.3 + dotnet core 3.0.100-preview3-010431
Steps to Reproduce:
Expected Behavior:
Given the signature of
Foo
, the compiler should be able to infer that the return type of theswitch
expression isobject
.Actual Behavior:
The compiler returns error
If I add a cast to
object
in any of the cases in theswitch
statement (e.g."a" => (object)1
) then the code compiles.The text was updated successfully, but these errors were encountered: