提交 b0b90053 编写于 作者: B BattleRush

New ErrorCode(8111) for local functions not having a body

https://github.com/dotnet/roslyn/issues/14900
上级 db1b86f3
...@@ -462,7 +462,7 @@ private BoundStatement BindLocalFunctionStatement(LocalFunctionStatementSyntax n ...@@ -462,7 +462,7 @@ private BoundStatement BindLocalFunctionStatement(LocalFunctionStatementSyntax n
block = null; block = null;
hasErrors = true; hasErrors = true;
// TODO(https://github.com/dotnet/roslyn/issues/14900): Better error message // TODO(https://github.com/dotnet/roslyn/issues/14900): Better error message
diagnostics.Add(ErrorCode.ERR_ConcreteMissingBody, localSymbol.Locations[0], localSymbol); diagnostics.Add(ErrorCode.ERR_LocalFunctionMissingBody, localSymbol.Locations[0], localSymbol);
} }
if (block != null) if (block != null)
......
...@@ -5911,6 +5911,15 @@ internal class CSharpResources { ...@@ -5911,6 +5911,15 @@ internal class CSharpResources {
} }
} }
/// <summary>
/// Looks up a localized string similar to &apos;{0}&apos; is a local function and must therefore always have a body..
/// </summary>
internal static string ERR_LocalFunctionMissingBody {
get {
return ResourceManager.GetString("ERR_LocalFunctionMissingBody", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to A local or parameter named &apos;{0}&apos; cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter. /// Looks up a localized string similar to A local or parameter named &apos;{0}&apos; cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter.
/// </summary> /// </summary>
......
...@@ -5073,4 +5073,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ ...@@ -5073,4 +5073,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ChangingReferencedAssemblyVersionNotAllowed" xml:space="preserve"> <data name="ChangingReferencedAssemblyVersionNotAllowed" xml:space="preserve">
<value>Changing the version of an assembly reference is not allowed during debugging: '{0}' changed version to {1}</value> <value>Changing the version of an assembly reference is not allowed during debugging: '{0}' changed version to {1}</value>
</data> </data>
<data name="ERR_LocalFunctionMissingBody" xml:space="preserve">
<value>'{0}' is a local function and must therefore always have a body.</value>
</data>
</root> </root>
\ No newline at end of file
...@@ -1343,6 +1343,7 @@ internal enum ErrorCode ...@@ -1343,6 +1343,7 @@ internal enum ErrorCode
#region diagnostics for local functions introduced in C# 7 #region diagnostics for local functions introduced in C# 7
ERR_DynamicLocalFunctionParamsParameter = 8108, ERR_DynamicLocalFunctionParamsParameter = 8108,
ERR_ExpressionTreeContainsLocalFunction = 8110, ERR_ExpressionTreeContainsLocalFunction = 8110,
ERR_LocalFunctionMissingBody = 8111, //https://github.com/dotnet/roslyn/issues/14900
#endregion diagnostics for local functions introduced in C# 7 #endregion diagnostics for local functions introduced in C# 7
#region diagnostics for instrumentation #region diagnostics for instrumentation
......
...@@ -286,7 +286,7 @@ private static AssemblySymbol MapAssemblyIdentityToResolvedSymbol(AssemblyIdenti ...@@ -286,7 +286,7 @@ private static AssemblySymbol MapAssemblyIdentityToResolvedSymbol(AssemblyIdenti
if (map.TryGetValue(identity, out symbol, (v1, v2, s) => true)) if (map.TryGetValue(identity, out symbol, (v1, v2, s) => true))
{ {
// TODO: https://github.com/dotnet/roslyn/issues/9004 // TODO: https://github.com/dotnet/roslyn/issues/9004
throw new NotSupportedException(string.Format(CSharpResources.ChangingReferencedAssemblyVersionNotAllowed, identity, symbol.Identity.Version); throw new NotSupportedException(string.Format(CSharpResources.ChangingReferencedAssemblyVersionNotAllowed, identity, symbol.Identity.Version));
} }
return new MissingAssemblySymbol(identity); return new MissingAssemblySymbol(identity);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册