Warning on implicit conversion of Unit
type to Object
#1237
jl0pd
started this conversation in
Type System
Replies: 1 comment
-
I guess you can pass anything to a method accepting object |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
F# allows to pass unit
()
to methods acceptingobject
. It's not desired in most cases since itUnit
always compiles tonull
, which means that we should've just passnull
insteadExample:
Looks quite innocent, but in this case
GC.KeepAlive
does nothing, since it have only single overloadKeepAlive: object? -> void
. Compiler invokes this method asGC.KeepAlive(null)
and by doing so hides important bugBeta Was this translation helpful? Give feedback.
All reactions