www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 520] New: Invariants allowed to call public functions

reply d-bugmail puremagic.com writes:

           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 digitalmars.com
        ReportedBy: deewiant gmail.com
OtherBugsDependingO 511

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

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

        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.

Nov 15 2006
parent d-bugmail puremagic.com writes:

bugzilla digitalmars.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

------- Comment #1 from bugzilla digitalmars.com  2008-07-09 22:33 -------
Fixed dmd 1.032 and 2.016

Jul 09 2008