dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.9k stars 783 forks source link

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

Open MangelMaxime opened 19 hours ago

MangelMaxime commented 19 hours ago

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):

T-Gro commented 18 hours ago

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