Bug 20997 – Missing example of scope guard executing after return statement
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-07-01T06:02:30Z
Last change time
2023-02-10T08:25:24Z
Keywords
pull
Assigned to
No Owner
Creator
Simen Kjaeraas
Comments
Comment #0 by simen.kjaras — 2020-07-01T06:02:30Z
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/[email protected]
[1]: https://dlang.org/spec/statement.html#scope-guard-statement
Comment #1 by dlang-bot — 2023-02-03T14:54:43Z
@BVRazvan created dlang/dlang.org pull request #3520 "Issue 20997 - Missing example of scope guard executing after return statement" fixing this issue:
- fix issue 20997
https://github.com/dlang/dlang.org/pull/3520
Comment #2 by dlang-bot — 2023-02-10T08:25:24Z
dlang/dlang.org pull request #3520 "Issue 20997 - Missing example of scope guard executing after return statement" was merged into master:
- 3f09e2af7eeff6eb24c18e45b408116509d860bc by Student USO VM User:
Fix Issue 20997 - Missing example of scope guard executing after return statement
https://github.com/dlang/dlang.org/pull/3520