You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One can instantiate tempalate that violates @safe constrains.
I think it is a bug, as if the template declaration is already in @safe scope, it is detected.
templateunsafe(T...) { enum unsafe = T[0]; }
@systemenumSYS_VAL = 55;
voidmain() @safe {
auto a = unsafe!SYS_VAL; // <-- This is undetected template_unsafe(T...) {enum _unsafe = T[0];}
auto b = _unsafe!SYS_VAL; // Deprecation: cannot access `@system` variable `SYS_VAL` in @safe code
}
The text was updated successfully, but these errors were encountered:
I think the correct solution here is for enum unsafe inside the template to itself be inferred as a @system variable, because it has a @system initializer. That inference is part of DIP 1035, but it looks like it isn't implemented yet, because the following example also compiles:
@systemenumSYS_VAL = cast(int*) 0xDEADBEEF;
int* p = SYS_VAL; // not inferred as @systemvoidmain() @safe
{
int oops = *p;
}
One can instantiate tempalate that violates
@safe
constrains.I think it is a bug, as if the template declaration is already in
@safe
scope, it is detected.The text was updated successfully, but these errors were encountered: