Type for default literal not inferred in C# 7.0 #30384
Labels
4 - In Review
A fix for the issue is submitted for review.
Area-Compilers
Bug
Resolution-Fixed
The bug has been fixed and/or the requested behavior has been implemented
Milestone
It seems the type for a default literal is not correctly inferred when using C# 7.0 or lower. In these cases:
calling
GetTypeInfo().ConvertedType
on the default literal results in an error type. This works as expected (returnsint
type) when using C# 7.1. Some simple cases work in C# 7.0 too such asint i = default;
andswitch (0) { case default: };
(both returnint
for converted type on the default literal).Is this by design? I think it would be good for the compiler to infer the type even when the language version isn't right, for good error recovery in the IDE. If that's not possible or desired, would it at least be possible to somehow find out what the type would have been if there wasn't an error? Thanks.
(Discovered in #30359 (comment))
Tagging @jcouv
The text was updated successfully, but these errors were encountered: