[Issue 520] New: Invariants allowed to call public functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 15 05:40:44 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=520

           Summary: Invariants allowed to call public functions
           Product: D
           Version: 0.174
          Platform: PC
               URL: http://www.digitalmars.com/d/class.html#invariants
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: deewiant at gmail.com
OtherBugsDependingO 511
             nThis:


This is similar to Issue 516. The following code is directly from the spec:

class Foo
{
    public void f() { }
    private void g() { }

    invariant
    {
        f();  // error, cannot call public member function from invariant
        g();  // ok, g() is not public
    }
}

According to the comments in the code and a paragraph in the spec the above
should fail to compile, yet it compiles fine (and, due to Issue 519, runs fine,
instead of falling to stack overflow). The compiler shouldn't allow this, as
there is no situation where this is useful: it's always an infinite loop.


-- 




More information about the Digitalmars-d-bugs mailing list