-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Milestone
Description
[Fact]
public void Test()
{
string source = @"
public class C
{
public static void Main()
{
(int a, _) = new C2();
new C2().Deconstruct(out dynamic d, out _);
int b = d;
(int e, _) = (d, 124);
}
}
class C2
{
public void Deconstruct(out dynamic x, out int y)
{
(x, y) = (2, 123);
}
}
";
var comp = CreateCompilation(source, options: TestOptions.DebugExe, targetFramework: TargetFramework.StandardAndCSharp);
comp.VerifyDiagnostics(
// (6,10): error CS0266: Cannot implicitly convert type 'dynamic' to 'int'. An explicit conversion exists (are you missing a cast?)
// (int a, _) = new C2();
Diagnostic(ErrorCode.ERR_NoImplicitConvCast, "int a").WithArguments("dynamic", "int").WithLocation(6, 10)
);
}
The implicit conversion exists, which can be observed on the following lines (no errors for them), and one of them is also a deconstruction (from a tuple):
int b = d;
(int e, _) = (d, 124);