www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17932] New: [scope] __traits(compiles, stmt) cannot test

https://issues.dlang.org/show_bug.cgi?id=17932

          Issue ID: 17932
           Summary: [scope] __traits(compiles, stmt) cannot test scope
                    violations
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: bugzilla digitalmars.com
          Reporter: code dawg.eu

cat > bug.d << CODE
void test()  safe
{
    int var;
    scope int* p;
    static int* escape;
    static assert(!__traits(compiles, { escape = p; }));
    escape = p;
}
CODE
dmd -c -dip1000 bug.d
----
bug.d(6): Error: static assert  !true is false
----

The static assertion should pass as the assignment is not allowed.

bug.d(7): Error: scope variable p assigned to non-scope escape

--
Oct 23