Bug 6766 – Forward reference error for default struct/class arguments

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-10-04T09:35:00Z
Last change time
2015-06-17T21:01:55Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
andrej.mitrovich
Blocks
340

Comments

Comment #0 by andrej.mitrovich — 2011-10-04T09:35:05Z
void test(Bar bar = Bar(1)) { } struct Bar { this(int x) { } } void main() { } Error: more initializers than fields of Bar This also affects structs and classes that have methods with default arguments that call ctors of typeof(this): class Foo { this(int x) { } void test(Foo foo = new Foo(1)) { } } struct Bar { this(int x) { } void test(Bar bar = Bar(1)) { } } void main() {} test.d(4): Error: no constructor for Foo test.d(10): Error: more initializers than fields of Bar
Comment #1 by hsteoh — 2014-11-06T01:29:32Z
Tested on git HEAD, the first case now works; the second case gives the error message: ------ test.d(4): Error: no constructor for Foo test.d(10): Error: cannot create a struct until its size is determined ------ So looks like the bug is partially fixed, but not quite there yet.
Comment #2 by k.hara.pg — 2015-03-06T15:02:39Z
Comment #3 by k.hara.pg — 2015-03-06T15:07:46Z
*** Issue 5223 has been marked as a duplicate of this issue. ***
Comment #4 by k.hara.pg — 2015-03-10T15:55:58Z
*** Issue 9397 has been marked as a duplicate of this issue. ***
Comment #5 by github-bugzilla — 2015-03-28T20:19:05Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a7bdba471111f09f7dba2fbbc6a3d91d8ba110e7 fix Issue 6766 - Forward reference error for default struct/class arguments https://github.com/D-Programming-Language/dmd/commit/b675901392ad8e6873e47f77172e6e36f49aa351 Merge pull request #4457 from 9rnsr/fix6766 Issue 6766 - Forward reference error for default struct/class arguments
Comment #6 by github-bugzilla — 2015-03-30T06:10:35Z
Comment #7 by dlang-bugzilla — 2015-06-10T23:17:25Z
*** Issue 14678 has been marked as a duplicate of this issue. ***
Comment #8 by github-bugzilla — 2015-06-17T21:01:55Z