[Issue 12346] Instantiating class with a private constructor results in a runtime error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 11 04:53:05 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12346


Mike <slavo5150 at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Inheriting from a class     |Instantiating class with a
                   |with a private constructor  |private constructor results
                   |results in a runtime error  |in a runtime error


--- Comment #1 from Mike <slavo5150 at yahoo.com> 2014-03-11 04:53:03 PDT ---
Turns out you don't even need inheritance to reproduce the problem.

/********** test.d ***************/
module test;

class TestClass : DoNotInstantiate
{
    private this() {}

    uint value;
}



/************ main.d **************/
void main()
{
    test.TestClass x; // <---  This should result in a compile-time error
    x.value = 10;     // <---  Runtime error. 
}

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


More information about the Digitalmars-d-bugs mailing list