dotnet/roslyn
IDE0059 generates ambiguity errors for overloads with `out`
Aperta
#38.053 aperta il 16 ago 2019
Area-IDEBugFeature - IDE0059IDE-CodeStylehelp wanted
Metriche repository
- Star
- (20.414 stelle)
- Metriche merge PR
- (Merge medio 6g 17h) (256 PR mergiate in 30 g)
Descrizione
Version Used: 3.3.0-beta3-19413-06+ac06df1bffb7b7fd0e5bf63cc91921af76b21e03
Steps to Reproduce:
class Program
{
static void Main()
{
string s;
Foo(out s);
int i;
Foo(out i);
}
static void Foo(out int blah) => blah = 0;
static void Foo(out string blah) => blah = "";
}
Fix All for IDE0059.
Expected Behavior: IDE0059 shouldn't be offered, or if it is, the generated code should employ some disambiguation mechanism.
Actual Behavior:
class Program
{
static void Main()
{
Foo(out _);
Foo(out _);
}
static void Foo(out int blah) => blah = 0;
static void Foo(out string blah) => blah = "";
}
which fails to compile:
1>Program.cs(5,9,5,12): error CS0121: The call is ambiguous between the following methods or properties: 'Program.Foo(out int)' and 'Program.Foo(out string)'
1>Program.cs(6,9,6,12): error CS0121: The call is ambiguous between the following methods or properties: 'Program.Foo(out int)' and 'Program.Foo(out string)'