Consider the following code
----------
import std.stdio;

void foo(bool x)
{
   if (x)
      scope(exit) writeln("exiting");
   writeln("body");
}
----------
If the scope(exit) isn't in a compound statement (ie, if it isn't inside {}), the 'scope' applies only to the statement itself, so that's identical to:
   if (x) writeln("exiting");
which is useless and probably not what was intended.
Ditto for scope(success).

Currently the scope(exit) doesn't get executed at all (it's bugzilla 1894). But I suspect that any such use of scope guards is a bug.
Can we just make it illegal?

Reply via email to