未验证 提交 18806459 编写于 作者: F Fred Silberberg 提交者: GitHub

Merge pull request #31402 from 333fred/add-pointer-test

Add test to show that pointers are disallowed.
......@@ -2369,5 +2369,21 @@ public class C {
// Expression<Func<string>> e0 = () => x ??= null;
Diagnostic(ErrorCode.ERR_ExpressionTreeCantContainNullCoalescingAssignment, "x ??= null").WithLocation(7, 45));
}
[Fact]
public void PointersDisallowed()
{
CreateCompilation(@"
class C
{
unsafe void M(int* i1, int* i2)
{
i1 ??= i2;
}
}", options: TestOptions.UnsafeReleaseDll).VerifyDiagnostics(
// (6,9): error CS0019: Operator '??=' cannot be applied to operands of type 'int*' and 'int*'
// i1 ??= i2;
Diagnostic(ErrorCode.ERR_BadBinaryOps, "i1 ??= i2").WithArguments("??=", "int*", "int*").WithLocation(6, 9));
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册