Thread overview | |||||
---|---|---|---|---|---|
|
September 02, 2013 [Issue 10952] New: struct ctor with defaulted parameters should not be allowed | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10952 Summary: struct ctor with defaulted parameters should not be allowed Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-02 09:59:30 PDT --- ----- struct S { this(int x = 1) { assert(0); } // never throws } void main() { auto s = S(); } ----- If we're really never going to support user-provided default ctors (like it is now), then the above should become a compile-time error. That default argument can't be used. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 02, 2013 [Issue 10952] struct ctor with defaulted parameters should not be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=10952 --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-02 10:09:41 PDT --- Additionally I'm curious about the class situation: class C { this(int x = 1) { assert(0); } } According to the DMDFE, this is *not* a default ctor, and yet, it's the only one generated in the assembly code. What exactly is the terminology for a default constructor (with regards to defaulted parameters)? It's also interesting that Object.factory returns null if you have any ctor, even one with with a defaulted parameter: ----- class C { this(int x = 1) { } } import std.stdio; void main() { auto c = Object.factory("test.C"); assert(c !is null); // fails } ----- So we have the situation where: auto s = S(); // works, but doesn't call the user ctor auto c = new C(); // works AND calls the user ctor Object.factory("test.C"); // works only if there's no user-ctor, even one with default parameters This is an inconsistent mess. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 17, 2013 [Issue 10952] struct ctor with defaulted parameters should not be allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=10952 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-17 12:15:53 PDT --- *** This issue has been marked as a duplicate of issue 3438 *** -- 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