Skip to content

Commit

Permalink
updated existing tests to test for modified error code
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcadeMode committed Oct 16, 2022
1 parent 283c3ac commit c64ba65
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Test/Semantic/Semantics/ArglistTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void Main()
TypedReference tr1 = default(TypedReference);
TypedReference tr2 = __makeref(tr1); // CS1601
TypedReference tr3 = __makeref(123); // CS1510
TypedReference tr4 = __makeref(P); // CS0206
TypedReference tr4 = __makeref(P); // CS8145
TypedReference tr5 = __makeref(R); // CS0199
}
static int P { get; set; }
Expand All @@ -229,9 +229,9 @@ static void Main()
// (9,40): error CS1510: A ref or out value must be an assignable variable
// TypedReference tr3 = __makeref(123); // CS1510
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "123").WithLocation(9, 40),
// (10,40): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (10,40): error CS8145: Auto-implemented properties cannot return by reference
// TypedReference tr4 = __makeref(P); // CS0206
Diagnostic(ErrorCode.ERR_RefProperty, "P").WithLocation(10, 40),
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "P").WithLocation(10, 40),
// (11,40): error CS0199: A static readonly field cannot be used as a ref or out value (except in a static constructor)
// TypedReference tr5 = __makeref(R); // CS0199
Diagnostic(ErrorCode.ERR_RefReadonlyStatic, "R").WithLocation(11, 40)
Expand Down
52 changes: 26 additions & 26 deletions src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8020,7 +8020,7 @@ void test2()
}

[Fact]
public void CS0206ERR_RefProperty()
public void CS8145ERR_RefProperty()
{
var text =
@"class C
Expand All @@ -8042,12 +8042,12 @@ void M()
}
";
CreateCompilation(text).VerifyDiagnostics(
// (14,15): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (14,15): error CS8145: Auto-implemented properties cannot return by reference
// M(ref P); // CS0206
Diagnostic(ErrorCode.ERR_RefProperty, "P").WithLocation(14, 15),
// (15,15): error CS0206: A property or indexer may not be passed as an out or ref parameter
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "P").WithLocation(14, 15),
// (15,15): error CS8145: Auto-implemented properties cannot return by reference
// M(out this.Q); // CS0206
Diagnostic(ErrorCode.ERR_RefProperty, "this.Q").WithLocation(15, 15));
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "this.Q").WithLocation(15, 15));
}

[Fact]
Expand Down Expand Up @@ -22850,22 +22850,22 @@ static void Test(Func<string, string> Baz)
}
}";
CreateCompilation(source).VerifyDiagnostics(
// (16,47): error CS1510: A ref or out argument must be an assignable variable
// (16,47): error CS1510: A ref or out value must be an assignable variable
// var z4 = new Func<string, string>(ref x => x);
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "x => x").WithLocation(16, 47),
// (17,47): error CS1510: A ref or out argument must be an assignable variable
// (17,47): error CS1510: A ref or out value must be an assignable variable
// var z5 = new Func<string, string>(ref Goo<string>(x => x));
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "Goo<string>(x => x)").WithLocation(17, 47),
// (18,43): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (18,43): error CS8145: Auto-implemented properties cannot return by reference
// var z6 = new Func<string, string>(ref BarP);
Diagnostic(ErrorCode.ERR_RefProperty, "ref BarP").WithLocation(18, 43),
// (19,47): error CS1510: A ref or out argument must be an assignable variable
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "ref BarP").WithLocation(18, 43),
// (19,47): error CS1510: A ref or out value must be an assignable variable
// var z7 = new Func<string, string>(ref new Func<string, string>(x => x));
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "new Func<string, string>(x => x)").WithLocation(19, 47),
// (20,43): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (20,43): error CS8145: Auto-implemented properties cannot return by reference
// var z8 = new Func<string, string>(ref Program.BarP);
Diagnostic(ErrorCode.ERR_RefProperty, "ref Program.BarP").WithLocation(20, 43),
// (21,47): error CS1510: A ref or out argument must be an assignable variable
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "ref Program.BarP").WithLocation(20, 43),
// (21,47): error CS1510: A ref or out value must be an assignable variable
// var z9 = new Func<string, string>(ref Program.Goo<string>(x => x));
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "Program.Goo<string>(x => x)").WithLocation(21, 47),
// (23,48): error CS1510: A ref or out value must be an assignable variable
Expand All @@ -22883,25 +22883,25 @@ static void Test(Func<string, string> Baz)
// (15,47): error CS0149: Method name expected
// var z3 = new Func<string, string>(ref k); // compat
Diagnostic(ErrorCode.ERR_MethodNameExpected, "k").WithLocation(15, 47),
// (16,47): error CS1510: A ref or out argument must be an assignable variable
// (16,47): error CS1510: A ref or out value must be an assignable variable
// var z4 = new Func<string, string>(ref x => x);
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "x => x").WithLocation(16, 47),
// (17,47): error CS1510: A ref or out argument must be an assignable variable
// (17,47): error CS1510: A ref or out value must be an assignable variable
// var z5 = new Func<string, string>(ref Goo<string>(x => x));
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "Goo<string>(x => x)").WithLocation(17, 47),
// (18,47): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (18,47): error CS8145: Auto-implemented properties cannot return by reference
// var z6 = new Func<string, string>(ref BarP);
Diagnostic(ErrorCode.ERR_RefProperty, "BarP").WithLocation(18, 47),
// (19,47): error CS1510: A ref or out argument must be an assignable variable
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "BarP").WithLocation(18, 47),
// (19,47): error CS1510: A ref or out value must be an assignable variable
// var z7 = new Func<string, string>(ref new Func<string, string>(x => x));
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "new Func<string, string>(x => x)").WithLocation(19, 47),
// (20,47): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (20,47): error CS8145: Auto-implemented properties cannot return by reference
// var z8 = new Func<string, string>(ref Program.BarP);
Diagnostic(ErrorCode.ERR_RefProperty, "Program.BarP").WithLocation(20, 47),
// (21,47): error CS1510: A ref or out argument must be an assignable variable
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "Program.BarP").WithLocation(20, 47),
// (21,47): error CS1510: A ref or out value must be an assignable variable
// var z9 = new Func<string, string>(ref Program.Goo<string>(x => x));
Diagnostic(ErrorCode.ERR_RefLvalueExpected, "Program.Goo<string>(x => x)").WithLocation(21, 47),
// (22,48): error CS1657: Cannot pass 'Id' as a ref or out argument because it is a 'method group'
// (22,48): error CS1657: Cannot use 'Id' as a ref or out value because it is a 'method group'
// var z10 = new Func<string, string>(ref Id); // compat
Diagnostic(ErrorCode.ERR_RefReadonlyLocalCause, "Id").WithArguments("Id", "method group").WithLocation(22, 48),
// (23,48): error CS1510: A ref or out value must be an assignable variable
Expand Down Expand Up @@ -23007,18 +23007,18 @@ static void Test(Func<string, string> Baz)
// (10,46): error CS0149: Method name expected
// var c = new Func<string, string>(ref Baz, ref Baz.Invoke);
Diagnostic(ErrorCode.ERR_MethodNameExpected, "Baz, ref Baz.Invoke").WithLocation(10, 46),
// (11,42): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (11,42): error CS8145: Auto-implemented properties cannot return by reference
// var d = new Func<string, string>(ref BarP, BarP.Invoke);
Diagnostic(ErrorCode.ERR_RefProperty, "ref BarP").WithLocation(11, 42),
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "ref BarP").WithLocation(11, 42),
// (11,46): error CS0149: Method name expected
// var d = new Func<string, string>(ref BarP, BarP.Invoke);
Diagnostic(ErrorCode.ERR_MethodNameExpected, "BarP, BarP.Invoke").WithLocation(11, 46),
// (12,42): error CS0149: Method name expected
// var e = new Func<string, string>(BarP, ref BarP.Invoke);
Diagnostic(ErrorCode.ERR_MethodNameExpected, "BarP, ref BarP.Invoke").WithLocation(12, 42),
// (13,42): error CS0206: A property or indexer may not be passed as an out or ref parameter
// (13,42): error CS8145: Auto-implemented properties cannot return by reference
// var f = new Func<string, string>(ref BarP, ref BarP.Invoke);
Diagnostic(ErrorCode.ERR_RefProperty, "ref BarP").WithLocation(13, 42),
Diagnostic(ErrorCode.ERR_AutoPropertyCannotBeRefReturning, "ref BarP").WithLocation(13, 42),
// (13,46): error CS0149: Method name expected
// var f = new Func<string, string>(ref BarP, ref BarP.Invoke);
Diagnostic(ErrorCode.ERR_MethodNameExpected, "BarP, ref BarP.Invoke").WithLocation(13, 46)
Expand Down

0 comments on commit c64ba65

Please sign in to comment.