fsharp
fsharp copied to clipboard
No compiler error when declaring multiple parameters with the same name in abstract methods
Repro steps
Provide the steps required to reproduce the problem:
- Define a type with an abstract member having two parameters with the same name.
- 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.
Agreed this should be fixed.