Commit ade14d4
committed
fix(ecmascript): enhance side-effect detection for classes, TypedArrays, computed members, and spread (#20213)
## Summary
Part of #19673
Several side-effect detection improvements:
- **Computed member expressions**: When `property_read_side_effects` is `None`, non-literal keys (e.g. `obj[identRef]`) now check the key expression and object for their own side effects instead of always returning `true`
- **ObjectExpression spread**: When `property_read_side_effects` is `None`, `{...expr}` delegates to the argument's own side effects
- **Class MethodDefinition**: Now checks for parameter decorators (TypeScript `@foo` on params)
- **Class AccessorProperty**: Now checks accessor property values for side effects
- **TypedArray constructors**: Added `Int8Array`, `Uint8Array`, `Uint8ClampedArray`, `Int16Array`, `Uint16Array`, `Int32Array`, `Uint32Array`, `Float32Array`, `Float64Array`, `BigInt64Array`, `BigUint64Array` to pure constructors (`DataView` excluded as it requires an `ArrayBuffer` argument)
## Test plan
- [x] Added tests for computed member non-literal keys with `property_read_side_effects`
- [x] Added tests for ObjectExpression spread with `property_read_side_effects`
- [x] Added tests for class method parameter decorators
- [x] Added tests for class accessor property values
- [x] Added tests for TypedArray constructors
- [x] All existing tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent e7163b6 commit ade14d4
File tree
2 files changed
+84
-10
lines changed- crates
- oxc_ecmascript/src/side_effects
- oxc_minifier/tests/ecmascript
2 files changed
+84
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| |||
641 | 644 | | |
642 | 645 | | |
643 | 646 | | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
650 | 659 | | |
651 | 660 | | |
652 | 661 | | |
| |||
701 | 710 | | |
702 | 711 | | |
703 | 712 | | |
704 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
705 | 716 | | |
706 | 717 | | |
707 | 718 | | |
| |||
710 | 721 | | |
711 | 722 | | |
712 | 723 | | |
713 | | - | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
714 | 727 | | |
715 | 728 | | |
716 | 729 | | |
| |||
767 | 780 | | |
768 | 781 | | |
769 | 782 | | |
770 | | - | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
771 | 794 | | |
772 | 795 | | |
773 | 796 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
76 | 90 | | |
77 | 91 | | |
78 | 92 | | |
| |||
751 | 765 | | |
752 | 766 | | |
753 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
754 | 773 | | |
755 | 774 | | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
756 | 779 | | |
757 | 780 | | |
758 | 781 | | |
| |||
913 | 936 | | |
914 | 937 | | |
915 | 938 | | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
916 | 954 | | |
917 | 955 | | |
918 | 956 | | |
| |||
1149 | 1187 | | |
1150 | 1188 | | |
1151 | 1189 | | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
1152 | 1196 | | |
1153 | 1197 | | |
1154 | 1198 | | |
1155 | 1199 | | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1156 | 1207 | | |
1157 | 1208 | | |
1158 | 1209 | | |
| |||
0 commit comments