anonymous functions and scope(exit)

Dennis dkorpel at gmail.com
Sat Jul 3 17:47:47 UTC 2021


On Saturday, 3 July 2021 at 17:20:47 UTC, Luis wrote:
> scope(exit) inside of a anonymous functions, it's never called.

I think the compiler infers the function `nothrow` since you 
don't throw any `Exception`, only an `Error`. Errors represent 
unrecoverable bugs, after which the program is in an invalid 
state, so the compiler is free to exit immediately without caring 
about destructors or `scope(exit)`. Use `Exception` instead of 
`Error` if you want the stack to properly unwind.


More information about the Digitalmars-d-learn mailing list