forked from jashkenas/coffeescript
-
Notifications
You must be signed in to change notification settings - Fork 58
Open
@jfgorski
Description
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'
Metadata
Metadata
Assignees
Labels
No labels