Skip to content

[Bug]: Pure annotations are incorrectly modified to wrong scope #14797

@hyrious

Description

@hyrious

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

(/* @__PURE__ */ f()).g()

REPL Link

Configuration file name

No response

Configuration

None

Current and expected behavior

Currently babel strips the parentheses of (/* @__PURE__ */ f()), causing the whole expression f().g() be marked as pure.

/* @__PURE__ */
f().g();

// expect: same as input

Environment

System:
  OS: macOS 12.5
Binaries:
  Node: 18.6.0 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 8.15.0 - /usr/local/bin/npm
npmPackages:
  @babel/core: ^7.7.4 => 7.18.9
  @babel/plugin-proposal-class-properties: ^7.7.4 => 7.18.6
  @babel/plugin-proposal-object-rest-spread: ^7.7.4 => 7.18.9
  @babel/plugin-transform-modules-commonjs: ^7.15.0 => 7.18.6
  @babel/preset-env: ^7.7.4 => 7.18.9
  @babel/preset-react: ^7.7.4 => 7.18.6
  @babel/preset-typescript: ^7.7.4 => 7.18.6
  babel-loader: ^8.0.6 => 8.2.5
  webpack: ^5.74.0 => 5.74.0

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commentsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions