Skip to content

var not reused if assigned in nested function #416

Closed
@tom-adsfund

Description

->
  var a
  ->
    a!
    a = ->

->
  var a
  ->
    a!

compiles to

(function(){
  var a;
  return function(){
    var a;
    a();
    return a = function(){};
  };
});
(function(){
  var a;
  return function(){
    return a();
  };
});

In the first function, because a is assigned after the call, a new var is created causing a to be undefined.

But in the second top-level function, a is not assigned, and so a is not undefined. (actually it is, but it wouldn't be if I'd assigned something before creating the nested function)

I wouldn't expect a new var to be created in the first one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions