You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)]
[Fact]
public void ObjectCreationFlow_75_CollectionInitializerError()
{
string source = @"
public class C
{
public static void Main()
/*<bind>*/{
int d = 1;
var c = new C() { [d] = {2} };
}/*</bind>*/
C2 _test1 = new C2();
C2 this[int x]
{
get => _test1;
}
}
class C2
{
}
";
var expectedDiagnostics = new[] {
// (7,33): error CS1922: Cannot initialize type 'C2' with a collection initializer because it does not implement 'System.Collections.IEnumerable'
// var c = new C() { [d] = {2} };
Diagnostic(ErrorCode.ERR_CollectionInitRequiresIEnumerable, "{2}").WithArguments("C2").WithLocation(7, 33)
};
string expectedFlowGraph = @"
";
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source, expectedFlowGraph, expectedDiagnostics);
}
Either we should relax the validation to specifically target the scenario, or we can slightly adjust the graph creation so that it included the capture as a child of an IInvalidOperation representing erroneous element add. The second is probably going to be easier to implement.
The text was updated successfully, but these errors were encountered:
…c` arguments (#72964)
Fixes#72750.
For C# 12 language version: behavior of the compiler in regards to deciding between whether binding should be static or dynamic is the same as behavior of C# 12 compiler. As a result, for affected scenarios, what used to have `dynamic` type in C# 12 compiler will have `dynamic` type when C# 12 language version is targeted.
For newer language versions: invocations statically bound in presence of dynamic arguments should have dynamic result if their dynamic binding succeeded in C# 12. Corresponding spec update - dotnet/csharplang#8027 at commit 8.
Related to #33011, #72906, #72912, #72913, #72914, #72916, #72931.
AlekseyTs
added a commit
to AlekseyTs/roslyn
that referenced
this issue
Apr 16, 2024
…c` arguments (dotnet#72964)
Fixesdotnet#72750.
For C# 12 language version: behavior of the compiler in regards to deciding between whether binding should be static or dynamic is the same as behavior of C# 12 compiler. As a result, for affected scenarios, what used to have `dynamic` type in C# 12 compiler will have `dynamic` type when C# 12 language version is targeted.
For newer language versions: invocations statically bound in presence of dynamic arguments should have dynamic result if their dynamic binding succeeded in C# 12. Corresponding spec update - dotnet/csharplang#8027 at commit 8.
Related to dotnet#33011, dotnet#72906, dotnet#72912, dotnet#72913, dotnet#72914, dotnet#72916, dotnet#72931.
Restore dynamic as result type of some operations involving dynamic arguments (#72964)
Fixes#72750.
For C# 12 language version: behavior of the compiler in regards to deciding between whether binding should be static or dynamic is the same as behavior of C# 12 compiler. As a result, for affected scenarios, what used to have dynamic type in C# 12 compiler will have dynamic type when C# 12 language version is targeted.
For newer language versions: invocations statically bound in presence of dynamic arguments should have dynamic result if their dynamic binding succeeded in C# 12. Corresponding spec update - dotnet/csharplang#8027 at commit 8.
Related to #33011, #72906, #72912, #72913, #72914, #72916, #72931.
Observed:
Either we should relax the validation to specifically target the scenario, or we can slightly adjust the graph creation so that it included the capture as a child of an
IInvalidOperation
representing erroneous element add. The second is probably going to be easier to implement.The text was updated successfully, but these errors were encountered: