Skip to content

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

@brianrourkeboll

Description

@brianrourkeboll

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions