Skip to content

TDZ transformer can't handle conditionally called code (T6640) #3707

@babel-bot

Description

@babel-bot

Issue originally made by @spicyj

Bug information

  • Babel version: 90327ae
  • Node version: 4
  • npm version: 2

Options

function transform(src) { console.log(require('./packages/babel-core').transform(src, {plugins: [[require('./packages/babel-plugin-transform-es2015-block-scoping'), {tdz: true}]]}).code); }

Input code

> transform('function f() {x;} Math.random() > 0.5 && f(); let x = 5; f();')
function f() {
  (function () {
    throw new ReferenceError("x is not defined - temporal dead zone");
  })();
}Math.random() > 0.5 && f();var x = 5;f();

Description

f should throw only if it's called before the let executes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRoutdatedA 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