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

Catch not running code after try/catch. #191

Open
jfgorski opened this issue Aug 16, 2016 · 0 comments
Open

Catch not running code after try/catch. #191

jfgorski opened this issue Aug 16, 2016 · 0 comments

Comments

@jfgorski
Copy link

In the compiled code below shouldn't the catch block do something with __iced_k like the try block does? So that console.log 'done' gets called if there's an exception while running the sync part of the try.

f = (cb) -> cb()
try
  console.log 'in try'
  throw new Error 'the error'
  await f defer err
catch exn
  console.log 'in catch'
console.log 'done'
// Generated by IcedCoffeeScript 108.0.11
(function() {
  var err, exn, f, iced, __iced_deferrals, __iced_k, __iced_k_noop;

  iced = require('iced-runtime');
  __iced_k = __iced_k_noop = function() {};

  f = function(cb) {
    return cb();
  };

  (function(_this) {
    return (function(__iced_k) {
      try {
        console.log('in try');
        throw new Error('the error');
        __iced_deferrals = new iced.Deferrals(__iced_k, {
          filename: "/home/jfgorski/dev/misc/iced-test-try-catch-bug.coffee"
        });
        f(__iced_deferrals.defer({
          assign_fn: (function() {
            return function() {
              return err = arguments[0];
            };
          })(),
          lineno: 5
        }));
        __iced_deferrals._fulfill();
      } catch (_error) {
        exn = _error;
        return console.log('in catch');
      }
    });
  })(this)((function(_this) {
    return function() {
      return console.log('done');
    };
  })(this));

}).call(this);

Adding an await in the catch fixes the problem:

f = (cb) -> cb()
try
  console.log 'in try'
  throw new Error 'the error'
  await f defer err
catch exn
  console.log 'in catch'
  await f defer err
console.log 'done'
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