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
// (5,18): error CS8352: Cannot use variable 'scoped T c2' in this context because it may expose referenced variables outside of their declaration scope
28645
+
// return X(c1 ??= c2);
28646
+
Diagnostic(ErrorCode.ERR_EscapeVariable, "c1 ??= c2").WithArguments("scoped T c2").WithLocation(5, 18),
28647
+
// (5,16): error CS8347: Cannot use a result of 'C.X<T>(T)' in this context because it may expose variables referenced by parameter 'c' outside of their declaration scope
// (13,18): error CS8352: Cannot use variable 'scoped T c2' in this context because it may expose referenced variables outside of their declaration scope
28651
+
// return X(c2 ??= c2);
28652
+
Diagnostic(ErrorCode.ERR_EscapeVariable, "c2 ??= c2").WithArguments("scoped T c2").WithLocation(13, 18),
28653
+
// (13,16): error CS8347: Cannot use a result of 'C.X<T>(T)' in this context because it may expose variables referenced by parameter 'c' outside of their declaration scope
// (17,18): error CS8352: Cannot use variable 'scoped T c2' in this context because it may expose referenced variables outside of their declaration scope
28657
+
// return X(c2 ??= c1);
28658
+
Diagnostic(ErrorCode.ERR_EscapeVariable, "c2 ??= c1").WithArguments("scoped T c2").WithLocation(17, 18),
28659
+
// (17,16): error CS8347: Cannot use a result of 'C.X<T>(T)' in this context because it may expose variables referenced by parameter 'c' outside of their declaration scope
Copy file name to clipboardExpand all lines: src/Compilers/CSharp/Test/Emit3/Semantics/ExtensionOperatorsTests.cs
+21-13Lines changed: 21 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -24692,9 +24692,18 @@ static class Extensions
24692
24692
// (8,23): error CS8352: Cannot use variable 'scoped C c1' in this context because it may expose referenced variables outside of their declaration scope
24693
24693
// return Y(c += c1);
24694
24694
Diagnostic(ErrorCode.ERR_EscapeVariable, "c1").WithArguments("scoped C c1").WithLocation(8, 23),
24695
+
// (12,16): error CS8347: Cannot use a result of 'C.Y(C)' in this context because it may expose variables referenced by parameter 'left' outside of their declaration scope
// (12,22): error CS8347: Cannot use a result of 'C.X(C, C)' in this context because it may expose variables referenced by parameter 'right' outside of their declaration scope
// (12,22): error CS8347: Cannot use a result of 'C.X(C, C)' in this context because it may expose variables referenced by parameter 'right' outside of their declaration scope
// (12,27): error CS8352: Cannot use variable 'scoped C c1' in this context because it may expose referenced variables outside of their declaration scope
24705
+
// return Y(c = X(c, c1));
24706
+
Diagnostic(ErrorCode.ERR_EscapeVariable, "c1").WithArguments("scoped C c1").WithLocation(12, 27),
24698
24707
// (12,27): error CS8352: Cannot use variable 'scoped C c1' in this context because it may expose referenced variables outside of their declaration scope
24699
24708
// return Y(c = X(c, c1));
24700
24709
Diagnostic(ErrorCode.ERR_EscapeVariable, "c1").WithArguments("scoped C c1").WithLocation(12, 27)
@@ -24893,9 +24902,12 @@ static class Extensions
24893
24902
// (12,16): error CS8347: Cannot use a result of 'C.Y(C)' in this context because it may expose variables referenced by parameter 'left' outside of their declaration scope
// (12,18): error CS8352: Cannot use variable 'scoped C c' in this context because it may expose referenced variables outside of their declaration scope
24905
+
// (12,22): error CS8347: Cannot use a result of 'C.X(C, C)' in this context because it may expose variables referenced by parameter 'left' outside of their declaration scope
// (12,24): error CS8352: Cannot use variable 'scoped C c' in this context because it may expose referenced variables outside of their declaration scope
24897
24909
// return Y(c = X(c, c1));
24898
-
Diagnostic(ErrorCode.ERR_EscapeVariable, "c = X(c, c1)").WithArguments("scoped C c").WithLocation(12, 18)
24910
+
Diagnostic(ErrorCode.ERR_EscapeVariable, "c").WithArguments("scoped C c").WithLocation(12, 24)
24899
24911
);
24900
24912
}
24901
24913
@@ -24942,16 +24954,19 @@ static class Extensions
24942
24954
// (12,16): error CS8347: Cannot use a result of 'C.Y(C)' in this context because it may expose variables referenced by parameter 'left' outside of their declaration scope
// (12,18): error CS8352: Cannot use variable 'scoped C c' in this context because it may expose referenced variables outside of their declaration scope
24957
+
// (12,22): error CS8347: Cannot use a result of 'C.X(C, scoped C)' in this context because it may expose variables referenced by parameter 'left' outside of their declaration scope
24946
24958
// return Y(c = X(c, c1));
24947
-
Diagnostic(ErrorCode.ERR_EscapeVariable, "c = X(c, c1)").WithArguments("scoped C c").WithLocation(12, 18)
// (12,24): error CS8352: Cannot use variable 'scoped C c' in this context because it may expose referenced variables outside of their declaration scope
24961
+
// return Y(c = X(c, c1));
24962
+
Diagnostic(ErrorCode.ERR_EscapeVariable, "c").WithArguments("scoped C c").WithLocation(12, 24)
24948
24963
);
24949
24964
}
24950
24965
24951
24966
/// <summary>
24952
24967
/// This is a clone of Microsoft.CodeAnalysis.CSharp.UnitTests.Semantics.RefEscapingTests.UserDefinedBinaryOperator_RefStruct_Compound_ScopedTarget_04
// (12,16): error CS8347: Cannot use a result of 'C.Y(C)' in this context because it may expose variables referenced by parameter 'left' outside of their declaration scope
// (12,18): error CS8352: Cannot use variable 'scoped C c' in this context because it may expose referenced variables outside of their declaration scope
24986
-
// return Y(c = X(c, c1));
24987
-
Diagnostic(ErrorCode.ERR_EscapeVariable, "c = X(c, c1)").WithArguments("scoped C c").WithLocation(12, 18)
0 commit comments