Skip to content

Latest commit

 

History

History
98 lines (68 loc) · 6.35 KB

File metadata and controls

98 lines (68 loc) · 6.35 KB

F# in .NET 11 Preview 5 - Release Notes

Here's a summary of what's new in F# in this Preview 5 release:

Return-value attributes are preserved in more signatures

Return-value attributes are now routed to the return metadata slot for more F# member shapes. Prefix [<return: ...>] attributes on class members are emitted to IL, no longer conflict with member-level attributes under AllowMultiple = false, and attributes on unparenthesized tuple return types are no longer dropped (dotnet/fsharp #19738, dotnet/fsharp #19714). Thank you @edgarfgp for these contributions!

open System

[<AttributeUsage(AttributeTargets.ReturnValue)>]
type ReturnDescriptionAttribute(text: string) =
    inherit Attribute()
    member _.Text = text

type Formatter =
    [<return: ReturnDescription("normalized text")>]
    member _.Normalize(value: string) = value.Trim()

    static member Pair(value: string) : [<return: ReturnDescription("two values")>] string * string =
        value, value.ToUpperInvariant()

Script files participate in parallel graph checking

Graph-based type checking now records modules that are implicitly provided by script files. Projects that include .fsx files can stay on the parallel checking path instead of falling back to sequential checking up to the last script file (dotnet/fsharp #19649). Thank you @majocha for this contribution!

// A.fsx
let value = 41
// B.fsx
#load "A.fsx"

let result = A.value + 1

Command-line warning controls apply during option parsing

--nowarn and --warnaserror now apply to warnings produced while the compiler parses command-line options. Option warnings now follow the same suppression and escalation rules as warnings reported later in compilation (dotnet/fsharp #19776).

fsc --nowarn:75 --extraoptimizationloops:1 Program.fs

F# 11 exception serialization preserves fields

When targeting frameworks where ISerializable exception serialization is available, F# 11 now emits serialization members for user-defined exceptions with fields. The generated members store and restore those fields through SerializationInfo, so round trips preserve the exception payload (dotnet/fsharp #19342, dotnet/fsharp #19746). This codegen is gated behind --langversion:11; earlier language versions keep the previous exception shape.

exception ParseFailed of line: int * message: string

let error = ParseFailed(12, "Unexpected token")
// On supported target frameworks, F# 11 emits serialization members
// that preserve both the line number and message fields.

Bug fixes and other improvements

Compiler correctness

  • Custom attribute arguments now handle more valid inputs: empty arrays of user-defined types compile, non-empty arrays of unencodable types report FS3887 instead of an internal compiler error, and optional primitive value-type attribute constructor parameters get the correct default values (dotnet/fsharp #19472, dotnet/fsharp #19484).
  • Attributes in namespace rec and module rec scopes now resolve opened namespaces before module attributes are checked (dotnet/fsharp #19502).
  • Nested inline SRTP functions with multiple overloads no longer hit internal error FS0073 during IL generation (dotnet/fsharp #19710). Thank you @gusty!
  • Pattern matching inside seq, list, and array comprehensions now narrows nullness correctly and avoids false-positive FS3261 warnings (dotnet/fsharp #19743).
  • Signature conformance now accepts an implementation member written as member M(()) for a signature member written as member M: unit -> unit when the generated IL shape is the same (dotnet/fsharp #19615).

Diagnostics

  • Overload-resolution errors now underline the terminal method identifier instead of the entire object access and argument expression. Symbol-use ranges reported through name resolution now use the terminal identifier for the same cases (dotnet/fsharp #19505).
  • Parser diagnostics in debug builds no longer expose internal parser-state details, and related parse errors have clearer wording (dotnet/fsharp #19730). Thank you @auduchinok!
  • use bindings no longer produce an internal compiler error when a C#-style Dispose extension method is in scope alongside IDisposable.Dispose (dotnet/fsharp #19568).

Community contributors

Thank you contributors! ❤️

F# updates: