From bbae3c0a60ad4408bdeaf403c30f8fd302420742 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Wed, 26 Jul 2017 13:26:45 -0700 Subject: [PATCH] Fixup tests. --- .../Test/Semantic/Semantics/ColorColorTests.cs | 3 --- .../Test/Semantic/Semantics/SemanticErrorTests.cs | 12 ++++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/ColorColorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/ColorColorTests.cs index 03a0676591211..67301c6deccb2 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/ColorColorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/ColorColorTests.cs @@ -1953,9 +1953,6 @@ void M() Assert.Equal(SymbolKind.Local, symbolInfo.Symbol.Kind); compilation.VerifyDiagnostics( - // (11,15): error CS0822: Implicitly-typed variables cannot be constant - // const var E = E.A; - Diagnostic(ErrorCode.ERR_ImplicitlyTypedVariableCannotBeConst, "var E = E.A").WithLocation(11, 15), // (11,23): error CS0841: Cannot use local variable 'E' before it is declared // const var E = E.A; Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "E").WithArguments("E").WithLocation(11, 23) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs index 4bcd5e51a133f..62d64bced4852 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs @@ -11537,12 +11537,9 @@ public static void Main() var comp = CreateStandardCompilation(text); comp.VerifyDiagnostics( - // (6,15): error CS0822: Implicitly-typed variables cannot be constant - // const var x = 0; // CS0822.cs - Diagnostic(ErrorCode.ERR_ImplicitlyTypedVariableCannotBeConst, "var x = 0").WithLocation(6, 15), - // (7,15): error CS0822: Implicitly-typed variables cannot be constant + // (7,23): error CS0133: The expression being assigned to 'y' must be constant // const var y = (int?)null + x; - Diagnostic(ErrorCode.ERR_ImplicitlyTypedVariableCannotBeConst, "var y = (int?)null + x").WithLocation(7, 15), + Diagnostic(ErrorCode.ERR_NotConstantExpression, "(int?)null + x").WithArguments("y").WithLocation(7, 23), // (7,23): warning CS0458: The result of the expression is always 'null' of type 'int?' // const var y = (int?)null + x; Diagnostic(ErrorCode.WRN_AlwaysNull, "(int?)null + x").WithArguments("int?").WithLocation(7, 23) @@ -11552,11 +11549,10 @@ public static void Main() [Fact] public void CS0822ERR_ImplicitlyTypedVariableCannotBeConst_Fields() { + // This is now legal. CreateCompilationWithMscorlib45(@" const var x = 0; // CS0822.cs -", parseOptions: TestOptions.Script).VerifyDiagnostics( - // (2,7): error CS0822: Implicitly-typed variables cannot be constant - Diagnostic(ErrorCode.ERR_ImplicitlyTypedVariableCannotBeConst, "var")); +", parseOptions: TestOptions.Script).VerifyDiagnostics(); } [Fact]