Skip to content

a variable named 'filter' can be incorrectly transformed by transform-runtime plugin #10205

Description

@bcutler-work

Bug Report

Current Behavior
When @babel/plugin-transform-runtime has corejs set to 3, it can incorrectly transform property access using a variable called filter. (Note: NOT the property filter.)

Actual output:

import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
var filter = 'foo';
var bar = {
  foo: function () {
    return 'foo';
  }
};
console.log(_filterInstanceProperty(bar).call(bar));

Input Code

var filter = 'foo';
var bar = { foo: function() { return 'foo';}};

console.log(bar[filter]());

Expected behavior/code

Expected output: (if corejs is set to false, this is the output, as expected)

var filter = 'foo';
var bar = {
  foo: function () {
    return 'foo';
  }
};
console.log(bar[filter]());

Babel Configuration

module.exports = (api) => {
  api.cache(true);
  return {
    'plugins': [
      ['@babel/plugin-transform-runtime', {
        'corejs': 3,
        'regenerator': true,
        'useESModules': true
      }]
    ],
  };
};

Environment

  • Babel version(s): (@babel/cli 7.5.0) (@babel/core 7.5.4) (@babel/plugin-transform-runtime 7.5.0)
  • Node/npm version: Node 10.13/npm 6.4.1/yarn 1.15.2
  • OS: OSX 10.13.6
  • Monorepo: N/A
  • How you are using Babel: cli for this example, but it was manifesting the same way with webpack

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

Metadata

Metadata

Assignees

Labels

Has PRclaimedgood first issueoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions