Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing named arguments + callback style and getter should not compile #17935

Open
MangelMaxime opened this issue Oct 29, 2024 · 2 comments · May be fixed by #17956
Open

Mixing named arguments + callback style and getter should not compile #17935

MangelMaxime opened this issue Oct 29, 2024 · 2 comments · May be fixed by #17956

Comments

@MangelMaxime
Copy link

I think the code below should not compile.

Repro steps

Provide the steps required to reproduce the problem:

type LabeledProperty = 

    abstract member alert: title:string * message:string option -> unit with get,set

Looking at the C# output it gives the following result which looks incomplete.

[CompilationMapping(SourceConstructFlags.Module)]
public static class @_
{
    [Serializable]
    [CompilationMapping(SourceConstructFlags.ObjectType)]
    public interface LabeledProperty
    {
        override Unit alert { get; set; }
    }
}

Expected behavior

F# compiler should fails the compilation ?

Provide any related information (optional):

  • Operating system: OSX
  • .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET Core 8.0.401
  • Editing Tools (e.g. Visual Studio Version, Visual Studio)
@github-actions github-actions bot added this to the Backlog milestone Oct 29, 2024
@T-Gro T-Gro changed the title Mixing named DUs + callback style and getter should not compile Mixing named arguments + callback style and getter should not compile Oct 29, 2024
@T-Gro
Copy link
Member

T-Gro commented Oct 29, 2024

Changed name, there is no "DU" involved in this case.

The codegen is definitely wrong.

Out of the 4 options here, only alert3 and alert4 are correct, the others are a bug/missing error:
https://sharplab.io/#v2:DYLgZgzgPg9gDgUwHYAIDKBPCAXBBbAWAChjsNEUBZDAMQFckBjFAXhRwCcBLJAcxQBU7bNz4p42LjFQBaAHwoGXbMVLkEKADIBDAEYJgCACYAFDvAQcyrFKqIoHKPZ22NsKPPn0cnhqyBRJbEMQTh5+IU8ICG1eBFCRcPE4SWkUeUUkZRQAd2UACxQ47AAaCAQVe0dnEVd3TzxvX0tsACYAsLEhTv4JKVkFJXc87ELisoriRyddFzcPL0tmqwBmAIAKHsFhUV6U/vTBrOwASlyCooqJyumajjqFxqXtP2wAFgDqeiZz0cvS8rYIA===

type MyFunc = string * string option -> unit

type LabeledProperty = 

    abstract member alert: title:string * message:string option -> unit with get,set
    abstract member alert2: string * string option -> unit with get,set
    abstract member alert3: (string * string option -> unit) with get,set
    abstract member alert4: MyFunc with get,set

@edgarfgp
Copy link
Contributor

edgarfgp commented Nov 5, 2024

It seems that it you use Item as the member name, aka Indexer properties(get, set) it adds the missing codegen. :)

type LabeledProperty =

    abstract member Item: title:string * message:string option -> unit with get,set
[CompilationMapping(SourceConstructFlags.Module)]
public static class @_
{
    [Serializable]
    [CompilationMapping(SourceConstructFlags.ObjectType)]
    public interface LabeledProperty
    {
        override Unit this[string title, FSharpOption<string> message] { get; set; }
    }
}

See sharplab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants