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

No compiler error when declaring multiple parameters with the same name in abstract methods #13148

Closed
brianrourkeboll opened this issue May 17, 2022 · 1 comment · Fixed by #14084
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@brianrourkeboll
Copy link
Contributor

Repro steps

Provide the steps required to reproduce the problem:

  1. Define a type with an abstract member having two parameters with the same name.
  2. It compiles, generating unutterable names for all repeated parameter names after the first.

Examples

type I =
    // Tupled.
    abstract M : i:int * i:int -> int
    // Curried.
    abstract N : i:int -> i:int -> int
    // More than two.
    abstract O : i:int * i: int * i:int -> int
    // Multiple distinct names repeated.
    abstract P : i:int * j:int * i:int * j:int -> int

generates (SharpLab)

[Serializable]
[CompilationMapping(SourceConstructFlags.ObjectType)]
public interface I
{
    override int M(int i, int i@3);

    [CompilationArgumentCounts(new int[] { 1, 1 })]
    override int N(int i, int i@5-1);

    override int O(int i, int i@7-2, int i@7-3);

    override int P(int i, int j, int i@9-4, int j@9);
}

Expected behavior

A compiler error disallowing multiple parameters with the same name in abstract methods.

Actual behavior

The code compiles, but the names of all repeated parameter names are unutterable.

Known workarounds

It is still possible to implement an abstract method so defined, although it is not possible to make the concrete implementation's parameters' names match those of the abstract method being overridden.

Related information

  • .NET SDK 6.0.300.
@dsyme
Copy link
Contributor

dsyme commented May 23, 2022

Agreed this should be fixed.

@dsyme dsyme added Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. and removed Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. labels May 23, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
@vzarytovskii vzarytovskii added this to the Backlog milestone Sep 21, 2022
Repository owner moved this from Not Planned to Done in F# Compiler and Tooling Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
Archived in project
3 participants