-
Notifications
You must be signed in to change notification settings - Fork 830
Closed
Labels
Milestone
Description
I found a weird issue while playing around with SRTPs.
Repro steps
type Numberish<'T when 'T: (static member Zero : 'T)> = 'T
let inline foo<'t when Numberish<'t>> = 't.Zero
foo<int> |> printfn "%d"
foo<int> |> printfn "%d"
foo<int> |> printfn "%d"
Expected behavior
I expect to see "0" printed three times.
Actual behavior
Nonsensical and nondeterministic output:
1448156832
1448165416
1448165728
Known workarounds
I have no clue. Frankly I'm not even sure how the SRTP resolution is working or what it's compiling to, given that System.Int32.Zero fails to compile (error FS0039: The type 'Int32' does not define the field, constructor or member 'Zero'), but whatever it's doing is nondeterministic.
Related information
Provide any related information (optional):
Reproes both in Microsoft (R) F# Interactive version 12.0.5.0 for F# 7.0 and in VS 2022 Version 17.4.3 with Visual F# Tools 17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done