Repository navigation
Commit 3d4815c
A setter with a defaulted formal param (`set m(x = 42)`) must report
`.length === 0` (defaults do not count toward a function's length), but
`class_accessor_function_value` hardcoded the reflected setter value's
length to 1, ignoring defaults. Reading
`Object.getOwnPropertyDescriptor(C.prototype, 'm').set.length` therefore
returned 1 instead of 0.
Fix: codegen now registers each setter's default-aware spec length
(`spec_function_length`) against its accessor func_ptr via
`js_register_closure_length`, and `class_accessor_function_value`
consults `lookup_closure_length` for the raw setter pointer, falling back
to the fixed 1/0 when no registration exists (native / cross-module
accessors). A plain `set m(x)` still reports 1; getters stay at 0.
Fixes test262 language/{statements,expressions}/class/setter-length-dflt.
Co-authored-by: Ralph Küpper <ralph@skelpo.com>
1 parent 82929c0 commit 3d4815c
2 files changed
Lines changed: 32 additions & 7 deletions
File tree
- crates
- perry-codegen/src/codegen
- perry-runtime/src/object/class_registry
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
963 | 964 | | |
964 | 965 | | |
965 | 966 | | |
966 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
967 | 976 | | |
968 | 977 | | |
969 | 978 | | |
| |||
999 | 1008 | | |
1000 | 1009 | | |
1001 | 1010 | | |
1002 | | - | |
| 1011 | + | |
| 1012 | + | |
1003 | 1013 | | |
1004 | 1014 | | |
1005 | 1015 | | |
1006 | | - | |
| 1016 | + | |
1007 | 1017 | | |
1008 | 1018 | | |
1009 | 1019 | | |
| |||
1015 | 1025 | | |
1016 | 1026 | | |
1017 | 1027 | | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
1018 | 1037 | | |
1019 | 1038 | | |
1020 | 1039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
| |||
0 commit comments