-
Notifications
You must be signed in to change notification settings - Fork 826
Closed
Closed
Copy link
Labels
Area-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genbugs in SRTP inference, resolution, witness passing, code genBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone
Description
When compiled with F# 9.0 this code produces a runtime error:
open System
let printTypeConstraintsNative<'T when 'T : unmanaged> () = printf $"Hello: {typeof<'T>.FullName} is unmanaged"
let Main() =
// null Seq
let func (x:int) : 'T when 'T : unmanaged = Unchecked.defaultof<'T>
let initFinite = Seq.init<nativeint> 3 func
printfn "%A" initFinite
printTypeConstraintsNative<nativeint>()
Main()
Program output:
c:\temp>c:\kevinransom\fsharp\artifacts\bin\fsc\Release\net472\fsc C:\Users\kevinr\source\repos\ConsoleApp82\ConsoleApp82\Program.fs
Microsoft (R) F# Compiler version 12.9.100.0 for F# 9.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
c:\temp>Program.exe
Hello: System.IntPtr is unmanaged
Unhandled Exception: System.TypeLoadException: Method 'Specialize' on type 'func@8' from assembly 'Program, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' tried to implicitly override a method with weaker type parameter constraints.
at Program.Main()
at <StartupCode$Program>.$Program.main@()
compile with F# 8.0 works fine.
Copilot
Metadata
Metadata
Assignees
Labels
Area-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genbugs in SRTP inference, resolution, witness passing, code genBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Type
Projects
Status
Done