mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Add parse support for multiple requirements after where separated by and (#4298)
Follow on to #4275 that added `where` parse support. --------- Co-authored-by: Josh L <josh11b@users.noreply.github.com> Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Josh L
Richard Smith
parent
6bfaa888e8
commit
d6b2fb1736
@@ -45,12 +45,20 @@ auto Tree::Verify() const -> ErrorOr<Success> {
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_errors() &&
|
||||
static_cast<int32_t>(size()) != tokens_->expected_parse_tree_size()) {
|
||||
// Not every token that can produce a virtual node will, so we only check that
|
||||
// the number of nodes is in a range.
|
||||
int32_t num_nodes = size();
|
||||
if (!has_errors() && num_nodes > tokens_->expected_max_parse_tree_size()) {
|
||||
return Error(llvm::formatv(
|
||||
"Tree has {0} nodes and no errors, but "
|
||||
"Lex::TokenizedBuffer expected {1} nodes for {2} tokens.",
|
||||
size(), tokens_->expected_parse_tree_size(), tokens_->size()));
|
||||
"Lex::TokenizedBuffer expected up to {1} nodes for {2} tokens.",
|
||||
num_nodes, tokens_->expected_max_parse_tree_size(), tokens_->size()));
|
||||
}
|
||||
if (!has_errors() && num_nodes < tokens_->size()) {
|
||||
return Error(
|
||||
llvm::formatv("Tree has {0} nodes and no errors, but expected at least "
|
||||
"{1} nodes to match the number of tokens.",
|
||||
num_nodes, tokens_->size()));
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
Reference in New Issue
Block a user