Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this get lost in try block #35

Open
shankerwangmiao opened this issue May 12, 2015 · 0 comments
Open

this get lost in try block #35

shankerwangmiao opened this issue May 12, 2015 · 0 comments

Comments

@shankerwangmiao
Copy link
Contributor

 a={}
  a.b=(cb)->
    console.log this
    try
      console.log this
      this.b cont()
    catch err
      console.error err
  a.b()

the output code is

(function () {
  var a;
  a = {};
  a.b = function (cb) {
    var err;
    console.log(this);
    (function (_$cont) {
      try {
        console.log(this);
        return this.b(function (arguments) {
          try {
            _$cont();
          } catch (_$err) {
            _$cont(_$err);
          }
        }.bind(this, arguments));
      } catch (_$err) {
        _$cont(_$err);
      }
    }(function (_error) {
      if (_error !== undefined) {
        err = _error;
        return console.error(err);
      }
    }));
  };
  a.b();
}.call(this));
/* Generated by Continuation.js v0.1.7 */

Apparently, this get lost in the structure

(function (_$cont) {
  //...
})(function (_error) {
})
@shankerwangmiao shankerwangmiao changed the title another "this" issue this get lost in try block May 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant