Skip to content

Delegates aren't getting inlined in certain cases, when using InlineIfLambda #15326

@vzarytovskii

Description

@vzarytovskii

SystemAction below is not getting inlined, as it used to prior .NET7p5

namespace FSharpConsole
module Foo =
    open System

    type SystemAction<'a
        when 'a: struct and 'a :> IConvertible>
            = delegate of byref<'a> -> unit

    let inline doAction (span: Span<'a>) ([<InlineIfLambda>] action: SystemAction<'a>) =
        for i = 0 to span.Length - 1 do
        	let batch = &span[i]
        	action.Invoke &batch
    [<EntryPoint>]
    let main args =
        let array = Array.zeroCreate 100
        doAction (array.AsSpan()) (SystemAction<int>(fun batch-> batch <- batch + 1))
        0

Last compiler where it worked - .NET7 p4 = 8854f5d 8854f5d1
Last compiler where it broke - .NET7p5 = a4208e9 a4208e91
Diff - https://github.com/dotnet/fsharp/compare/8854f5d1..a4208e91
Commits - 8854f5d...a4208e9
Likely suspect - 1b39cde

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.Regression

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions