February 18, 2021 [Issue 19885] possibility to skip required initialization in constructor using ref parameter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19885 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> --- I think that the behavior was designed to allow for: initializeA(ref A a) { a = A(2); } struct B { A a; this(int) { initializeA(a); } } This is a common pattern and forbidding this might brake a lot of code. However, there is no way the compiler can know if the function actually initializes a or not. The problem with `out` is slightly different. Since A does not have default construction the parameter cannot be initialized before entering the function. Also, there is this issue [1], which was fixed by considering that taking the address of a variable in the constructor is the same as initializing it. Passing a field by ref to a function could be seen the same as taking its address, so by those standards this issue would be a WONTFIX. [1] https://issues.dlang.org/show_bug.cgi?id=15869 -- |
October 28, 2021 [Issue 19885] possibility to skip required initialization in constructor using ref parameter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19885 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WONTFIX -- |
Copyright © 1999-2021 by the D Language Foundation