Repository navigation
Commit fd5a049
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 07cb321 commit fd5a049
2 files changed
Lines changed: 34 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1082 | 1082 | | |
1083 | 1083 | | |
1084 | 1084 | | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
1085 | 1091 | | |
1086 | | - | |
1087 | 1092 | | |
1088 | 1093 | | |
1089 | 1094 | | |
| |||
| 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 | | |
| |||
1373 | 1386 | | |
1374 | 1387 | | |
1375 | 1388 | | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
1376 | 1395 | | |
1377 | 1396 | | |
1378 | 1397 | | |
| |||
1468 | 1487 | | |
1469 | 1488 | | |
1470 | 1489 | | |
1471 | | - | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
1472 | 1497 | | |
1473 | 1498 | | |
1474 | 1499 | | |
| |||
1480 | 1505 | | |
1481 | 1506 | | |
1482 | 1507 | | |
1483 | | - | |
1484 | | - | |
| 1508 | + | |
| 1509 | + | |
1485 | 1510 | | |
1486 | 1511 | | |
1487 | 1512 | | |
| |||
0 commit comments