[Issue 20997] New: Missing example of scope guard executing after return statement
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 1 06:02:30 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20997
Issue ID: 20997
Summary: Missing example of scope guard executing after return
statement
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dlang.org
Assignee: nobody at puremagic.com
Reporter: simen.kjaras at gmail.com
As pointed out on the forum[0], the documentation[1] for scope guards should
include an example with a return statement. Something like this:
import std.stdio;
int fun() {
scope (exit) writeln("Scope guard");
return gun();
}
int gun() {
writeln("Inside gun()");
return 3;
}
Will print:
Inside gun()
Scope guard
[0]: https://forum.dlang.org/thread/qzhhdjqvjxsycuxjdefo@forum.dlang.org
[1]: https://dlang.org/spec/statement.html#scope-guard-statement
--
More information about the Digitalmars-d-bugs
mailing list