Skip to content

[Compiler Bug]: Compiler tries to assign to variables that does not exist #33577

@SimenB

Description

@SimenB

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/#N4Igzg9grgTgxgUxALhASwLYAcIwC4AEwBUYCASgmGgF4IDyARmTAG4IwEC+BAZjBAwEAOiAACMBAEM4eALRSYaKQHooeNABswogNzCAdphz4iBAAoQc7GAGEIBvAgAeeADQky9xy7zmBWGDcfAJCopIy8orKcnCCOAYIjjog+gaGLiaEcQZghJbWHAQAvAQAFIYEZnAAFloAJpIGHlJGGFIaDgAisB1oDh4A7mj1eDUlIiB4SgDmMxyUvKIeAHRrWAFBXG6VBJK8OwYAlCUAfES7ANobVmAe+wC6E6QI3k6u-rdlN4H3CAcWKwQGxvXxHNJVHJ5MzTNBzBb-YKlH5gNK7F6Uah0JgsGxlYj7ZAEWHwmCLDwOTG0BDccGGXaSPCwAwEAxQTSaNJcNIgLhAA

Repro steps

t2 is not defined, so there's a runtime JS error (ReferenceError: assignment to undeclared variable t2).

Screenshot of buggy output for reference when bug is fixed in compiler:

Image

Note that removing width = "triggerRef" or const { triggerRef } = props; makes the bug disappear.

How often does this bug happen?

Every time

What version of React are you using?

N/A

What version of React Compiler are you using?

RC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions