www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6453] New: Allow multiple invariant per struct/class

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453

           Summary: Allow multiple invariant per struct/class
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simendsjo gmail.com



I would like to use a template mixin to add some fields to a struct, but I'd
also like the template to add additional invariant checks without having to
remember to add this for all struct/classes that mixes in this code.

class C {
    int a;
}

mixin template EmbedC() {
    C _c;

    // oops.. more than one invariant
    invariant() {
        assert(_c);
    }

    void close() {
        _c = null;
    }
}

struct S {
    int i = 10;
    invariant() {
        assert(i >= 10);
    }

    mixin EmbedC!();
}

void main() {
    S s;
    s.close();
    s._c.a = 10; // access violation, but I want assertion from invariant
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ddoc
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         AssignedTo|nobody puremagic.com        |yebblies gmail.com
         OS/Version|Windows                     |All
           Severity|normal                      |enhancement



The spec explicitly states that there can only be one invariant, so this is an
enhancement.

On the other hand, this appears to be an arbitrary restriction.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 28 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



https://github.com/D-Programming-Language/dmd/pull/653

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 28 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453


Alex Rønne Petersen <xtzgzorex gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xtzgzorex gmail.com



12:59:01 PST ---
I completely agree with this change; I ran into this exact limitation for the
exact same scenario as well. It's rather crippling for template mixins.


this enhancement IMHO.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ah08010-d yahoo.com



*** Issue 5038 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ae70bfdeafd3a534e3f12747503bafa046be2f9d
fix Issue 6453 - Allow multiple invariant per struct/class

https://github.com/D-Programming-Language/dmd/commit/081c92a115b3006871c5a516267417e06ceacbcf


Issue 6453 - Allow multiple invariant per struct/class

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ce58435fe322afd736504f804bdad6a9debb8c1d
Fix up for issue 6453 change, allow shared/synchronized invariants

But mixing non-shared/shared/synchronized is currently rejected.

https://github.com/D-Programming-Language/dmd/commit/4fbc77fa504c2d8ee4c7ef10edc70221a74742c3


Fix up for issue 6453 change, allow shared/synchronized invariants

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 12 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6453


Kenji Hara <k.hara.pg gmail.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2013