Commit 8ecb1ba
fix(compiler): recover invalid parenthesized expressions (#61815)
When the expression parser consumes tokens inside a parenthesized expression, it looks for valid tokens until it hits and invalid one or a closing paren. If it finds an invalid token, it reports and error and tries to recover until it finds a closing paren. The problem is that in such cases, it would produce the `ParenthesizedExpression` and continue parsing **from** from the closing paren which would then produce more errors that add noise to the output and result in an incorrect representation of the user's code. E.g. `foo((event.target as HTMLElement).value)` would be recovered to `foo((event.target)).value` instead of `foo((event.target).value)`.
These changes resolve the issue by skipping over the closing paren at the recovery point.
Fixes #61792.
PR Close #618151 parent f180f3d commit 8ecb1ba
File tree
2 files changed
+34
-4
lines changed- packages/compiler
- src/expression_parser
- test/expression_parser
2 files changed
+34
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1043 | 1049 | | |
1044 | | - | |
1045 | 1050 | | |
1046 | 1051 | | |
1047 | 1052 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
661 | 674 | | |
662 | 675 | | |
663 | 676 | | |
| |||
1355 | 1368 | | |
1356 | 1369 | | |
1357 | 1370 | | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
1358 | 1377 | | |
1359 | 1378 | | |
1360 | 1379 | | |
| |||
1445 | 1464 | | |
1446 | 1465 | | |
1447 | 1466 | | |
1448 | | - | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
1449 | 1474 | | |
1450 | 1475 | | |
1451 | 1476 | | |
| |||
1457 | 1482 | | |
1458 | 1483 | | |
1459 | 1484 | | |
1460 | | - | |
1461 | | - | |
| 1485 | + | |
| 1486 | + | |
1462 | 1487 | | |
1463 | 1488 | | |
1464 | 1489 | | |
| |||
0 commit comments