Avoid deep tree comparison when both trees have errors
This commit is contained in:
parent
c53f9bcbd9
commit
8f028ebf68
3 changed files with 5 additions and 2 deletions
|
|
@ -452,6 +452,8 @@ static bool parser__select_tree(Parser *self, Tree *left, Tree *right) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (left->error_cost > 0) return -1;
|
||||
|
||||
int comparison = ts_tree_compare(left, right);
|
||||
switch (comparison) {
|
||||
case -1:
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ if ({a: 'b'} {c: 'd'}) {
|
|||
|
||||
(program
|
||||
(if_statement
|
||||
(ERROR (object (pair (identifier) (string))))
|
||||
(object (pair (identifier) (string)))
|
||||
(ERROR (statement_block (labeled_statement (identifier) (expression_statement (string)))))
|
||||
(statement_block
|
||||
(expression_statement (assignment
|
||||
(identifier)
|
||||
|
|
|
|||
|
|
@ -398,7 +398,8 @@ describe("Parser", [&]() {
|
|||
|
||||
assert_root_node(
|
||||
"(program "
|
||||
"(expression_statement (number) (ERROR (number))) "
|
||||
"(ERROR (number)) "
|
||||
"(expression_statement (number)) "
|
||||
"(expression_statement (math_op (number) (number))))");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue