提交 c313611b 编写于 作者: N Neal Gafter

Add a regression test regarding binding local functions in incomplete code.

Related to #10521
上级 a5a17a2f
......@@ -3,6 +3,7 @@
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using System;
using Xunit;
......@@ -3693,5 +3694,28 @@ void Local()
// Local();
Diagnostic(ErrorCode.ERR_UseDefViolation, "Local").WithArguments("Local").WithLocation(9, 9));
}
[Fact, WorkItem(10521, "https://github.com/dotnet/roslyn/issues/10521")]
public void LocalFunctionInIf()
{
var source = @"
class Program
{
static void Main(string[] args)
{
if () // typing at this point
int Add(int x, int y) => x + y;
}
}
";
VerifyDiagnostics(source,
// (6,13): error CS1525: Invalid expression term ')'
// if () // typing at this point
Diagnostic(ErrorCode.ERR_InvalidExprTerm, ")").WithArguments(")").WithLocation(6, 13),
// (7,9): error CS1023: Embedded statement cannot be a declaration or labeled statement
// int Add(int x, int y) => x + y;
Diagnostic(ErrorCode.ERR_BadEmbeddedStmt, "int Add(int x, int y) => x + y;").WithLocation(7, 9)
);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册