mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Implement basic bool and int formatting for diagnostics (#4411)
Note, this supports plurals, but doesn't apply it anywhere. I'm mainly doing that to demonstrate the approach regarding syntax. See format_providers.h for details.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#include "toolchain/diagnostics/format_providers.h"
|
||||
#include "toolchain/parse/context.h"
|
||||
#include "toolchain/parse/handle.h"
|
||||
|
||||
@@ -36,10 +37,9 @@ static auto HandlePeriodOrArrow(Context& context, NodeKind node_kind,
|
||||
return;
|
||||
} else {
|
||||
CARBON_DIAGNOSTIC(ExpectedIdentifierAfterPeriodOrArrow, Error,
|
||||
"expected identifier after `{0}`", llvm::StringLiteral);
|
||||
context.emitter().Emit(
|
||||
*context.position(), ExpectedIdentifierAfterPeriodOrArrow,
|
||||
is_arrow ? llvm::StringLiteral("->") : llvm::StringLiteral("."));
|
||||
"expected identifier after `{0:->|.}`", BoolAsSelect);
|
||||
context.emitter().Emit(*context.position(),
|
||||
ExpectedIdentifierAfterPeriodOrArrow, is_arrow);
|
||||
// If we see a keyword, assume it was intended to be a name.
|
||||
// TODO: Should keywords be valid here?
|
||||
if (context.PositionKind().is_keyword()) {
|
||||
|
||||
Reference in New Issue
Block a user