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

[Compiler Bug]: object's get syntax is missing after compilation. #29586

Closed
1 of 4 tasks
Y-Hui opened this issue May 25, 2024 · 3 comments
Closed
1 of 4 tasks

[Compiler Bug]: object's get syntax is missing after compilation. #29586

Y-Hui opened this issue May 25, 2024 · 3 comments
Labels
Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@Y-Hui
Copy link

Y-Hui commented May 25, 2024

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwFkBPAQU0wAoAlPmAAdNvjiswBGWVwJ8AXhHj86-AHMEBQtABGlBADUylKAiGqJG-DB2w2AJnwAqfE4DcajQF8fvt50Pva4jvgAPIRMAG4AfMByCgB0elCGJmYWvhEA9NHxQf50IL5AA

Repro steps

const state = {
  get doubleValue() {
    return 2 * 2;
  }
};

In the above code, doubleValue uses get syntax, and after compilation, it loses the get keyword and becomes an ordinary function. In this case the compiler should skip compilation until this syntax is supported.

I know that some syntaxes are currently unsupported by the react compiler, can we know what syntaxes are currently unsupported and in process?

How often does this bug happen?

Every time

What version of React are you using?

19.0.0-rc-4c2e457c7c-20240522

@Y-Hui Y-Hui added Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels May 25, 2024
@josephsavona
Copy link
Contributor

Thanks for posting, this is a bug. We have not added support for get/set syntax but looks like we missed a todo for this.

josephsavona added a commit that referenced this issue May 25, 2024
We were missing a check that ObjectMethods are not getters or setters. In our experience this is pretty rare within React components and hooks themselves, so let's start with a todo.

Closes #29586

[ghstack-poisoned]
josephsavona added a commit that referenced this issue May 25, 2024
We were missing a check that ObjectMethods are not getters or setters. In our experience this is pretty rare within React components and hooks themselves, so let's start with a todo.

Closes #29586

ghstack-source-id: 03c6cce9a9368a4a4f4ba98bcdff3fa4729ceaf9
Pull Request resolved: #29592
@poteto poteto closed this as completed May 29, 2024
@josephsavona josephsavona reopened this May 29, 2024
@josephsavona
Copy link
Contributor

Let’s close when the associated PR lands

@poteto
Copy link
Member

poteto commented May 29, 2024

Oops my bad, I didn't read

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants