Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure decorators are callable #16388

Merged
merged 2 commits into from Mar 28, 2024
Merged

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
51 checks passed
@JLHwung JLHwung deleted the assert-callable-decorator branch March 28, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

4 participants