scope guard question

Arjan arjan at ask.me.to
Tue Jun 30 06:56:29 UTC 2020


On Monday, 29 June 2020 at 22:47:16 UTC, Steven Schveighoffer 
wrote:
> Yes. The return statement is inside the scope of the function, 
> so it runs before the scope is exited. Are you saying the spec 
> doesn't say that?

Thanks for the assurance. The spec does state it like this:
```
The ScopeGuardStatement executes NonEmptyOrScopeBlockStatement at 
the close of the current scope, rather than at the point where 
the ScopeGuardStatement appears.
```
Which is correct, but there is no single example with a return 
where the ScopeBlockStatement interferes with the return.

I started wondering about this since I hit a bug in a piece of 
code.


More information about the Digitalmars-d-learn mailing list