fix(es/decorators): drop params from getter replacing decorated private method - #12161
Conversation
…te method
A decorated private method is rewritten into a private getter that returns
the extracted call target. The rewrite reset `is_async` and `is_generator`
but left `params` untouched, so a method declared with parameters produced
a getter with formal parameters:
get #a(x, y) { return _call_a; }
which is a SyntaxError ("Getter must not have any formal parameters").
Nothing in the swc pipeline caught this: the transform output is only
serialized by codegen, which emits `Function::params` regardless of
`MethodKind`, and the parser's `GetterParam` check is a recoverable error
that the fixture harness discards. Only running the emitted code in a real
engine surfaces it.
Clear `params` when switching the member to `MethodKind::Getter`. The
parameters stay on the extracted function, which is where they belong.
Covered by new `private-with-params` fixtures for both decorator versions
(plain, default + rest, destructuring, and static parameters), including an
exec fixture that runs the output.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 21db9d6 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance
Comparing Footnotes
|
Description:
Decorating a private method rewrites it into a private getter returning the extracted call target. The rewrite reset
is_asyncandis_generatorbut notparams, so a method with parameters produced an invalid getter:Clearing
paramson the switch toMethodKind::Getterfixes it. The parameters remain on the extracted function.No existing test caught this: codegen emits
Function::paramsregardless ofMethodKind, and the parser'sGetterParamcheck is a recoverable error the fixture harness discards. Only running the output surfaces it, so the 2023-11 fixture includes anexeccase.Related issue (if exists):
None