Skip to content

Block scoped func decl id scoping #18

@pvdz

Description

@pvdz

I think Tenko currently doesn't properly scope the id of a function declaration that's inside a block (or switch).

If I understand properly now then in strict mode it becomes a let that is hoisted within the block and if not strict mode then it becomes a var that is hoisted within the block.

So:

{
  f();
  function f(){}
}

In context of where f binds, is really

{
  var f = function(){}
  f();
}

(Note the discrepancies with .name and some other things. This is only supposed to illustrate how f binds.)

While

"use strict";
{
  function f(){}
  f();
}

Is really

"use strict";
{
  let f = function(){}
  f();
}

Works the same in global, in functions, and in switches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions