scope guard question

Steven Schveighoffer schveiguy at gmail.com
Tue Jun 30 12:18:14 UTC 2020


On 6/30/20 2:56 AM, Arjan wrote:
> 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.

I can see where it would be confusing, and it could probably contain an 
example and clarification.

-steve


More information about the Digitalmars-d-learn mailing list