Skip to content

hoisted function declared inside IIFE may not return (fibers and generators modes only) #259

@bjouhier

Description

@bjouhier

Repro:

var api = (function() {
    function foo(_, arg) {
        console.log("FOO ARG=" + arg);
        return arg + " world";
    }
    return {
        foo: foo,
    };
})();

function bar(_) {
    var result = api.foo(_, "hello");
    console.log("RESULT=" + result);    
}

bar(function(err) {
    console.log("DONE: " + err);
});

Expecting:

FOO ARG=hello
RESULT=hello world
DONE: null

but getting:

FOO ARG=hello

Notes:

  • this bug only shows up in fibers and generators mode. It does not show up in callbacks mode nor in fast modes.
  • this bug only occurs if function are hoisted. If function bar() is changed to var bar = function() the bug disappears. So it does not impact CoffeeScript code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions