-
Notifications
You must be signed in to change notification settings - Fork 833
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
Two snippets below fails with NRE
- Equality
type Bar = { b: obj }
type Foo = { f: Bar | null }
let a = { f = null }
let b = { f = null }
a = bError
System.NullReferenceException: Object reference not set to an instance of an object.
at FSI_0045.Foo.Equals(Foo obj, IEqualityComparer comp)
at <StartupCode$FSI_0048>.$FSI_0048.main@()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Stopped due to error
- Hash code
type Bar = { b: obj }
type Foo = { f: Bar | null }
let a = { f = null }
a.GetHashCode()Error
System.NullReferenceException: Object reference not set to an instance of an object.
at FSI_0017.Foo.GetHashCode(IEqualityComparer comp)
at FSI_0017.Foo.GetHashCode()
at <StartupCode$FSI_0019>.$FSI_0019.main@()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Stopped due to error
Known workarounds
change Bar to be NON record
type Bar = class end
type Foo = { f: Bar | null }
let a = { f = null }
let b = { f = null }
a = b // works nowRelated information
- Windows 10
- Microsoft (R) F# Interactive version 12.9.101.0 for F# 9.0
dotnet --list-sdks
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.203 [C:\Program Files\dotnet\sdk]
6.0.321 [C:\Program Files\dotnet\sdk]
6.0.428 [C:\Program Files\dotnet\sdk]
7.0.120 [C:\Program Files\dotnet\sdk]
7.0.203 [C:\Program Files\dotnet\sdk]
7.0.317 [C:\Program Files\dotnet\sdk]
7.0.410 [C:\Program Files\dotnet\sdk]
8.0.112 [C:\Program Files\dotnet\sdk]
8.0.308 [C:\Program Files\dotnet\sdk]
8.0.405 [C:\Program Files\dotnet\sdk]
9.0.102 [C:\Program Files\dotnet\sdk]
ForNeVeR and gbtb
Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
New