Better diagnostics for nullness inference related errors
I think it would be good to be more explicit about nullness inference happening behind the scenes.
For the code
let xs = [| ""; ""; null |]
we'll get
Nullness warning: The type 'string' does not support 'null'
It would be helpful to have something like
"xs was inferred to have the type
string[]but got null among its values. Either explicitly specify null in the return type ((string | null)[]), or remove null from the collection - or suppress the warning but no please don't."
Originally posted by @psfinaki in https://github.com/dotnet/fsharp/pull/15181#discussion_r1679527189
We don't differentiate between collections and other types. string and string array are no different for us. This would probably be better solved in analyzers, rather than typechecker.
Related to: https://github.com/dotnet/fsharp/issues/17409
Option: Specialize type unification for list/array/sequence builders.
Diagnostics can offer: Explicit annotation or "be first" rule.