www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18757] New: static invariant{} should either work or not be

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

          Issue ID: 18757
           Summary: static invariant{} should either work or not be valid
                    syntax
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Right now, you can define a struct to have a static invariant:

struct S {
  static invariant { assert(false); }
  static void foo() { }
}

But the invariant will not be checked when calling foo.

Either this should work, or "static invariant {}" should be a syntax error.

--
Apr 12 2018