Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 13, 2010 [Issue 4636] New: scoped + private constructor | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from David Simcha <dsimcha@yahoo.com> 2010-08-12 18:33:26 PDT --- 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: ------- |
September 11, 2013 [Issue 4636] scoped + private constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=4636 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra@gmail.com --- Comment #1 from monarchdodra@gmail.com 2013-09-10 23:50:24 PDT --- 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: ------- |
September 11, 2013 [Issue 4636] scoped + private constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=4636 Dicebot <public@dicebot.lv> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |public@dicebot.lv --- Comment #2 from Dicebot <public@dicebot.lv> 2013-09-11 08:17:54 PDT --- 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: ------- |
September 11, 2013 [Issue 4636] scoped + private constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | 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 --- Comment #3 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-09-11 08:37:33 PDT --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation