digitalmars.D.bugs - [Issue 4636] New: scoped + private constructor
- d-bugmail puremagic.com (30/30) Aug 12 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4636
- d-bugmail puremagic.com (12/12) Sep 10 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4636
- d-bugmail puremagic.com (15/15) Sep 11 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4636
- d-bugmail puremagic.com (20/20) Sep 11 2013 http://d.puremagic.com/issues/show_bug.cgi?id=4636
http://d.puremagic.com/issues/show_bug.cgi?id=4636 Summary: scoped + private constructor Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: dsimcha yahoo.com import std.typecons; class Foo { private this(int num) {} } void main() { auto s = scoped!Foo(1); } d:\dmd2\windows\bin\..\..\src\phobos\std\conv.d(3903): Error: static assert "Don't know how to initialize an object of type Foo with arguments (int _param_1)" d:\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(2314): instantiated from here: emplace!(Foo,int) test9.d(8): instantiated from here: scoped!(Foo,int) Changing the c'tor to public fixes this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 12 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4636 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra gmail.com Is this really valid? If the constructor is private, then how could "scoped" (or "emplace" in this case) be expected to call it? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 10 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4636 Dicebot <public dicebot.lv> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |public dicebot.lv This is invalid as per current D specification but once again highlights fundamental flaw of protection attribute resolution done from definition scope for templates. Semantically it is the same module who constructs the Foo and access to private constructor is expected. But in fact it is done in `scoped` body which does reside in different module and this does not have access. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 11 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4636 Maxim Fomin <maxim maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rejects-valid | Status|NEW |RESOLVED CC| |maxim maxim-fomin.ru Platform|Other |All Resolution| |WONTFIX OS/Version|Windows |All --- This can be probably fixed by providing additional parameter which takes a delegate to private constructor (in a scope which have access to it) as an argument (with default null value). But it looks like it would require hoard of additional parameters along call chain which probably does not worth issue. Right now I close it as WONTFIX, but if some wants to fix, this can be reopened. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 11 2013