-
Notifications
You must be signed in to change notification settings - Fork 832
Closed
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.(Internal MS Team use only) Describes an issue with extreme impact on existing code.
Milestone
Description
Right now implicit type conversion happens only one-step (like int-> float or float -> Nullable<float>), but when we try to do two-step conversion (e.g. int -> Nullable<float>) there is no warning on compile time and we've exception in runtime.
Repro steps
type C() =
member val X = System.Nullable(1.0) with get, set
C(X = 1)Expected behavior
The code either works or gives compiler warning
Actual behavior
The code compiles successfully but in runtime the exception is raised
Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.Nullable`1[System.Double]'.
Known workarounds
Fix the code (e.g. write C(X = 1.0)) after facing the error in the runtime
Related information
dotnet 6.0.201
fsharp 6.0.3
En3Tho
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.(Internal MS Team use only) Describes an issue with extreme impact on existing code.
Type
Projects
Status
Done