Skip to content

Null value returned from trait call #12386

Closed

Description

@gusty

There are some cases where an invalid value is returned from a trait call.

Repro steps

  1. Step A

try in fsi

type A = A with
    static member ($) (A, a: float  ) = 0.0
    static member ($) (A, a: decimal) = 0M
    static member ($) (A, a: 't     ) = 0

let inline call x = ($) A x

send it

  1. Step B

Now try this call 42.

Expected behavior

val it : float = 0.0

Actual behavior

val it : obj = <null>

Known workarounds

I haven't found one so far.

  • Operating system: Windows
  • FSI: F# Interactive version 11.4.2.0 for F# 5.0
  • Editing Tools: Visual Studio 2019

I didn't try in older versions, but I'm under the impression that this is a regression.

Activity

  1. gusty commented on Nov 13, 2021

    @gusty
    ContributorAuthor

    And here's a repro to send to FSI in one shot

    type A = A with
        static member ($) (A, a: float  ) = 0.0
        static member ($) (A, a: decimal) = 0M
        static member ($) (A, a: 't     ) = 0
    
    let inline call x = ($) A x
    
    
    call 42.  + 1.1
    

    Which results in

    type A =
      | A
      with
        static member ( $ ) : A:A * a:'t -> int + 2 overloads
      end
    val inline call :
      x: ^a ->  ^_arg3
        when (A or  ^a) : (static member ( $ ) : A *  ^a ->  ^_arg3)
    val it : float = nan
    

    when the expeced result should be 1.1

  2. added
    Impact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.
    on Mar 3, 2022
  3. removed
    Impact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.
    on Mar 9, 2022
  4. added
    Area-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code gen
    and removed on Mar 31, 2022
  5. added
    Impact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.
    Impact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.
    and removed
    Impact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.
    on Jul 11, 2022
  6. edgarfgp commented on Sep 19, 2022

    @edgarfgp
    Contributor

    @gusty I have tried today with on a script and on fsi and seems to be fixed now :)
    FYI @vzarytovskii
    Screenshot 2022-09-19 at 14 57 33

  7. gusty commented on Sep 19, 2022

    @gusty
    ContributorAuthor

    Yes, it works for me as well.
    I wonder what was the fixing PR.

  8. 9 remaining items

  9. github-actions commented on Mar 22, 2026

    @github-actions
  10. auduchinok commented on Mar 23, 2026

    @auduchinok
    Member

    The issue seems to be reproducing per comments above. Should we add regression tests for the cases reported there instead of closing the issue?

  11. gusty commented on Mar 23, 2026

    @gusty
    ContributorAuthor

    I can confirm, it still repro in F# 10

    @T-Gro please re-open

  12. added a commit that references this issue on Mar 24, 2026
  13. reopened this on Mar 24, 2026
  14. T-Gro commented on Mar 26, 2026

    @T-Gro
    Member

    The bot was wrong (the repro needed a multi-submit FSI session, it did not reproduce in any other constellation).
    The solution is to treat interactive similar to how lib+app scenario works by having fresh solutions to type parameter constraints (lib+app scenario handles this via pickling that always refreshes).

    Good news is that fix is on the way.

  15. github-actions commented on Apr 1, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    Removing the AI-thinks-issue-fixed label. The previous Repo Assist comment was incorrect — the original repro (multi-submit FSI session) was not properly tested. As @auduchinok and @gusty confirmed, the issue still reproduces in F# 10/11. @T-Gro has identified the root cause and a fix is in progress (#19471).

    Apologies for the false positive.

    Tested on: d507366 (2026-04-01), F# Interactive 15.2.100.0 for F# 11.0, FSharp.Core 11.0.100.

    Generated by Repo Assist · ◷

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@9135cdfde26838a01779aa966628308404ec1f02
    
  16. added 2 commits that reference this issue on Apr 14, 2026
  17. added a commit that references this issue on Apr 14, 2026
    2bd5398
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-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.Regression

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions