Repository navigation
Commit 223d709
authored
fix(javascript): keep a dropped class whose effects read its own private name (#22421)
* fix(javascript): keep a dropped class whose effects read its own private name
Dropping an unused class kept its computed keys and static values but moved
them outside it, where a #private name it declares is no longer declared, so
class C { [o.#f] = 1; #f = 2 } became o.#f and stopped parsing, as terser's
output does. The correct phase now keeps such a class, and only for a name it
declares. 4 more test262 cases print in the printer's mode.
* fix(javascript): read a nested class's private names as its own when keeping a dropped class
A class nested in a dropped class's key that declares the same #name reads
its own, so the outer class was kept where terser drops it. The check now
reads such a class's body without the names it declares, and its extends
with all of them. Tests cover class expressions, private methods, getters,
setters, static methods and nested classes, one per branch the check takes.1 parent e6183e8 commit 223d709
4 files changed
Lines changed: 175 additions & 5 deletions
File tree
- .changeset
- lib/javascript
- test
- specCases
- unitCases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14703 | 14703 | | |
14704 | 14704 | | |
14705 | 14705 | | |
| 14706 | + | |
| 14707 | + | |
| 14708 | + | |
| 14709 | + | |
| 14710 | + | |
| 14711 | + | |
| 14712 | + | |
| 14713 | + | |
| 14714 | + | |
| 14715 | + | |
| 14716 | + | |
| 14717 | + | |
| 14718 | + | |
| 14719 | + | |
| 14720 | + | |
| 14721 | + | |
| 14722 | + | |
| 14723 | + | |
| 14724 | + | |
| 14725 | + | |
| 14726 | + | |
| 14727 | + | |
| 14728 | + | |
| 14729 | + | |
| 14730 | + | |
| 14731 | + | |
| 14732 | + | |
| 14733 | + | |
| 14734 | + | |
| 14735 | + | |
| 14736 | + | |
| 14737 | + | |
| 14738 | + | |
| 14739 | + | |
| 14740 | + | |
| 14741 | + | |
| 14742 | + | |
| 14743 | + | |
| 14744 | + | |
| 14745 | + | |
| 14746 | + | |
| 14747 | + | |
| 14748 | + | |
| 14749 | + | |
| 14750 | + | |
| 14751 | + | |
| 14752 | + | |
| 14753 | + | |
| 14754 | + | |
| 14755 | + | |
| 14756 | + | |
| 14757 | + | |
| 14758 | + | |
| 14759 | + | |
| 14760 | + | |
| 14761 | + | |
| 14762 | + | |
| 14763 | + | |
| 14764 | + | |
| 14765 | + | |
| 14766 | + | |
| 14767 | + | |
| 14768 | + | |
| 14769 | + | |
| 14770 | + | |
| 14771 | + | |
| 14772 | + | |
| 14773 | + | |
| 14774 | + | |
| 14775 | + | |
14706 | 14776 | | |
14707 | 14777 | | |
14708 | 14778 | | |
| |||
19298 | 19368 | | |
19299 | 19369 | | |
19300 | 19370 | | |
| 19371 | + | |
| 19372 | + | |
| 19373 | + | |
| 19374 | + | |
| 19375 | + | |
| 19376 | + | |
| 19377 | + | |
| 19378 | + | |
| 19379 | + | |
| 19380 | + | |
19301 | 19381 | | |
19302 | 19382 | | |
19303 | 19383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1517 | 1517 | | |
1518 | 1518 | | |
1519 | 1519 | | |
1520 | | - | |
1521 | | - | |
1522 | 1520 | | |
1523 | 1521 | | |
1524 | 1522 | | |
1525 | 1523 | | |
1526 | | - | |
1527 | | - | |
1528 | 1524 | | |
1529 | 1525 | | |
1530 | 1526 | | |
| |||
1617 | 1613 | | |
1618 | 1614 | | |
1619 | 1615 | | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
1620 | 1620 | | |
1621 | 1621 | | |
1622 | 1622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
522 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
523 | 580 | | |
524 | 581 | | |
525 | 582 | | |
| |||
3608 | 3665 | | |
3609 | 3666 | | |
3610 | 3667 | | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
3611 | 3696 | | |
3612 | 3697 | | |
3613 | 3698 | | |
| |||
0 commit comments