ClojureScript

named fn lexical scoping bug

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

(fn [foo] (fn foo [] foo))

generates the following code

function (foo) {
    return (function foo() {
        return foo__$1;
    });
}

Activity

David Nolen made changes -
Field Original Value New Value
Description {code}
(fn []
  (let [foo 1]
    (fn foo []
      (aset (array) 0 foo))))
{code}

generates the following

{code}
function () {
    var foo = 1;
    return ((function (foo) {
        return (function foo() {
            return ([][0] = foo__$1);
        });
    })(foo));
}
{code}
{code}
(fn []
  (let [foo 1]
    (fn foo []
      (aset (array) 0 foo))))
{code}

generates the following

{code}
function () {
    var foo = 1;
    return ((function (foo) {
        return (function foo() {
            return ([][0] = foo__$1);
        });
    })(foo));
}
{code}

A simpler case is

{code}
(fn [foo] (fn foo [] foo))
{code}

generates

{code}
function (foo) {
    return (function foo() {
        return foo__$1;
    });
}
{code}
David Nolen made changes -
Assignee David Nolen [ dnolen ]
David Nolen made changes -
Description {code}
(fn []
  (let [foo 1]
    (fn foo []
      (aset (array) 0 foo))))
{code}

generates the following

{code}
function () {
    var foo = 1;
    return ((function (foo) {
        return (function foo() {
            return ([][0] = foo__$1);
        });
    })(foo));
}
{code}

A simpler case is

{code}
(fn [foo] (fn foo [] foo))
{code}

generates

{code}
function (foo) {
    return (function foo() {
        return foo__$1;
    });
}
{code}
{code}
(fn [foo] (fn foo [] foo))
{code}

generates the following code

{code}
function (foo) {
    return (function foo() {
        return foo__$1;
    });
}
{code}
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Summary lexical scoping bug named fn lexical scoping bug
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: