www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23326] New: invariant syntax is inconsistently strict for

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

          Issue ID: 23326
           Summary: invariant syntax is inconsistently strict for
                    annotations
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: acehreli yahoo.com

struct S {
  void foo()  nogc {}   // fine

   nogc void foo() {}   // fine

   nogc invariant() {}  // fine

  invariant()  nogc {}  /* compilation errors:
    Error: statement expected to be `{ }`, not ` `
    Error: basic type expected, not `{`
    Error: declaration expected, not `{`
                        */
}

That example uses  nogc but it's the same with other attributes like  safe,
pure, etc.

--
Sep 04 2022