Skip to content

Indexer setters don't work with optional parameters #20046

Description

@ijklam

F#'s Indexer setters don't work with optional parameters, but C#'s do.

Related #9369

Repro steps

open System.Runtime.CompilerServices

type A() =
    member this.Item
        with get (key: string, [<CallerFilePath>]?path: string, [<CallerLineNumber>]?line: int) = 
            printfn "%A" (key, path, line)
            "_"

        // error FS1212: Optional arguments must come at the end of the argument list, after any non-optional arguments
        and set (key: string, [<CallerFilePath>]?path: string, [<CallerLineNumber>]?line: int) (value: string) = 
            printfn "%A" (key, path, line)

let t = A()
t["a"]

Related information

Provide any related information (optional):

  • .NET Runtime kind: .NET 11
  • Editing Tools: dotnet fsi

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    Status
    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions