[Issue 22025] New: Exception within a delegate can't be thrown.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 15 09:53:03 UTC 2021


          Issue ID: 22025
           Summary: Exception within a delegate can't be thrown.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bitworld at qq.com

When throwing an exception within a delegate, the app crashed.

My OS is macOS Big Sur 11.4. It's OK in Linux.

Tested compilers: DMD 2.088.1 - 2.097.0

Here is the sample:

void main() {
    int factor = 2;
    auto ex2a = new Promise!int();

    auto ex2b = ex2a.then!(async!((int x) { 
            if(x == 30) {
                // It's a bug in macOS Big Sur 11.4
                throw new Exception("throw an exception!");
            return x * factor; 

    ex2a.resolve(30); // throw an exception!

The steps are here for reproducing this bug:

$ git clone https://github.com/Heromyth/future.git
$ cd future
$ dub run


More information about the Digitalmars-d-bugs mailing list