Assigning a scope variable to an outer-scope variable is allowed?
"のしいか (noshiika)"
noshiika at gmail.com
Wed Jul 4 00:25:59 PDT 2007
Hello. I have a question about "scope" variables.
I've understood that it is not allowed to copy a scope variable or a
scope parameter to outside of the scope. But, the following code
compiles without any warnings or errors, and of course, causes a runtime
error.
Is this just a bug?
//----
class C {
~this() { writefln("dtor"); }
void func() { }
}
void main() {
C a;
{ scope C b = new C;
a = b;
} // dtor
if(a !is null) a.func(); // Error: Access Violation
}
const(int[]) g;
void foo(in int[] a) { // in == final const scope
g = a; // a is scope?
}
More information about the Digitalmars-d
mailing list