Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Don't warn FS3559 when obj is inferred if the obj is expected there #16454

Open

Description

@cmeeren

The new FS3559 triggers where I think it should not. Consider this:

let foo (x: obj) = ()
foo null

It triggers on null:

A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn "3559"' or '--nowarn:3559'.

But the type of the argument is explicitly obj, so it doesn't make sense that it should trigger here.

Another slightly more realistic example:

let invokeStatic (mi: System.Reflection.MethodInfo) =
    mi.Invoke(null, [||])

MethodInfo.Invoke expects obj as its first argument, so F# inferring obj here should not cause a warning.

Activity

  1. added this to the Backlog milestone on Dec 20, 2023
  2. Smaug123 commented on Dec 22, 2023

    @Smaug123
    Contributor

    Yeah, a verbatim null is one of the most annoying cases. I tried to fix this and could not :( which is not to say it's impossible, but the required information did not appear to be present locally at the point where the warning is generated.

    (The second most annoying case is typeof<Foo<_>>, where the _ is inferred as obj.)

    Tried to have another look just now, but I'm back to my usual state of being unable to build the compiler.

  3. added
    Impact-Low
    Area-Diagnostics
    and removed on Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-DiagnosticsBugImpact-Lowhelp wanted

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions