Skip to content

Ensure decorators are callable#16388

Merged
JLHwung merged 2 commits intobabel:mainfrom
JLHwung:assert-callable-decorator
Mar 28, 2024
Merged

Ensure decorators are callable#16388
JLHwung merged 2 commits intobabel:mainfrom
JLHwung:assert-callable-decorator

Conversation

@JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Mar 28, 2024

Q                       A
Fixed Issues? A non-callable decorator should be rejected. REPL
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

In the REPL example,

const nonCallable = { call() {}, bind() {}, apply() {} }

@nonCallable
class C {
  @nonCallable field;
  @nonCallable method() {}
}

we should have asserted the decorator is callable before we invoke the call method, as is required by the spec 7.3.13 Call. We have similar guards for initializers and the decorated class, but somehow we missed the decorators.

@JLHwung JLHwung added PR: Spec Compliance 👓 A type of pull request used for our changelog categories Spec: Decorators labels Mar 28, 2024
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56587

@JLHwung JLHwung merged commit efcc01c into babel:main Mar 28, 2024
@JLHwung JLHwung deleted the assert-callable-decorator branch March 28, 2024 23:21
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Spec Compliance 👓 A type of pull request used for our changelog categories Spec: Decorators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants