[Issue 9665] Structure constant members can not be initialized if have opAssign
https://issues.dlang.org/show_bug.cgi?id=9665 Walter Brightchanged: What|Removed |Added See Also||https://issues.dlang.org/sh ||ow_bug.cgi?id=18708 --
[Issue 9665] Structure constant members can not be initialized if have opAssign
https://issues.dlang.org/show_bug.cgi?id=9665 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added CC||hst...@quickfur.ath.cx --- Comment #32 from Kenji Hara k.hara...@gmail.com --- *** Issue 9372 has been marked as a duplicate of this issue. *** --
[Issue 9665] Structure constant members can not be initialized if have opAssign
https://issues.dlang.org/show_bug.cgi?id=9665 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added CC||monarchdo...@gmail.com --- Comment #31 from Kenji Hara k.hara...@gmail.com --- *** Issue 11952 has been marked as a duplicate of this issue. *** --
[Issue 9665] Structure constant members can not be initialized if have opAssign
https://d.puremagic.com/issues/show_bug.cgi?id=9665 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added CC||wfunct...@hotmail.com --- Comment #30 from Kenji Hara k.hara...@gmail.com 2013-11-28 20:39:34 PST --- *** Issue 8118 has been marked as a duplicate of this issue. *** -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #29 from github-bugzi...@puremagic.com 2013-11-03 20:49:18 PST --- Commit pushed to 2.064 at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/101d3a7a229b45bd97bc922f7c4df465f72d2432 Merge pull request #404 from 9rnsr/fix9665 Issue 9665 - Structure constant members can not be initialized if have opAssign -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #28 from github-bugzi...@puremagic.com 2013-11-03 20:47:08 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/76bf0a581313aa6f2702f23a577f28d32a5d385f fix Issue 9665 - Structure constant members can not be initialized if have opAssign Describe about field initialization behavior. https://github.com/D-Programming-Language/dlang.org/commit/0af070ef719ef65ddd325dfb5d68b5fd987ce6aa Merge pull request #404 from 9rnsr/fix9665 Issue 9665 - Structure constant members can not be initialized if have opAssign -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added CC||acehr...@yahoo.com --- Comment #27 from Kenji Hara k.hara...@gmail.com 2013-10-20 02:32:33 PDT --- *** Issue 9732 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added Keywords||pull, rejects-valid Blocks||11186, 11246, 10357 --- Comment #22 from Kenji Hara k.hara...@gmail.com 2013-10-14 05:58:29 PDT --- https://github.com/D-Programming-Language/dmd/pull/2665 https://github.com/D-Programming-Language/phobos/pull/1637 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #23 from github-bugzi...@puremagic.com 2013-10-14 15:19:11 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/644e11ea46ac671b4a1a34a31ef5e72a6f89a2d2 fix Issue 9665 - Structure constant members can not be initialized if have opAssign https://github.com/D-Programming-Language/phobos/commit/5f725db1141d98c67ee3515f4edb7b43692173d7 Merge pull request #1637 from 9rnsr/fix9665 Supplemental fix for issue 9665 - Structure constant members can not be initialized if have opAssign -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #24 from github-bugzi...@puremagic.com 2013-10-14 15:20:11 PDT --- Commit pushed to 2.064 at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f5606620c5f106694a6c1ec082587d8ffba1a6c7 Merge pull request #1637 from 9rnsr/fix9665 Supplemental fix for issue 9665 - Structure constant members can not be initialized if have opAssign -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #26 from github-bugzi...@puremagic.com 2013-10-14 20:51:57 PDT --- Commit pushed to 2.064 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/44d568a7f83a43d6bbd31cbcfcf194da39a3beb7 Merge pull request #2665 from 9rnsr/fix9665 Issue 9665 - Structure constant members can not be initialized if have opAssign -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #25 from github-bugzi...@puremagic.com 2013-10-14 20:51:16 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f8386c7eeb2518779e42e753507538188c1e3be5 fix Issue 9665 - Structure constant members can not be initialized if have opAssign - Change the first field assignment inside constructor to true initialization. - Disable multiple initialization of non-mutable field, if it is once initialized. https://github.com/D-Programming-Language/dmd/commit/84ee9522f470cdb90031c4a8542c32e753d1462c Merge pull request #2665 from 9rnsr/fix9665 Issue 9665 - Structure constant members can not be initialized if have opAssign -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added CC||samu...@voliacable.com --- Comment #19 from Kenji Hara k.hara...@gmail.com 2013-10-10 05:14:26 PDT --- *** Issue 11204 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #21 from Max Samukha samu...@voliacable.com 2013-10-10 07:10:42 PDT --- (In reply to comment #20) I see there was a discussion in bug 9665. - ignore this sentence. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #18 from Kenji Hara k.hara...@gmail.com 2013-05-07 04:25:59 PDT --- (In reply to comment #17) So Kenji, did you fix this bug in trunk? In local I've tried to fix this, but it had broke Phobos compilation by the lack of proper postblit feature. Sorry... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #17 from Andrei Alexandrescu and...@erdani.com 2013-05-05 19:00:14 PDT --- So Kenji, did you fix this bug in trunk? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #14 from Andrei Alexandrescu and...@erdani.com 2013-03-10 12:33:50 PDT --- (In reply to comment #13) (In reply to comment #9) This is an insufficiency in D's design. I think we should approach this the same way as super() invocation and construction of qualified objects This is close to const vs postblit problem. The problem appeared due to unthoughtful decision to allow const objects mutation during construction. But it is too late now. I disagree it's too late, seeing as I actually propose a solution. Also, this is probably not the best forum to air criticisms about the competence and state of mind of the language designers. 3. This raw state lasts until super() has been called EXACTLY ONCE and each qualified field has been assigned to EXACTLY ONCE. I am afraid such limitation would hurt programming in cases when raw object is touched more than once. I agree it would disallow some correct code, but it's not a strong limitation to ask for exactly one initialization. By the way, what is about example in comment 1 when non-const opAssign stores mutable pointer to immutable data? I'm not sure what you mean. What about it? This can't occur in the proposed raw/cooked design. 4. At that point the object has become cooked and all restrictions are lifted. Kenji, I recall we discussed this design in the context of const and immutable constructors, and you were favorable to it. How about we extend the same design for initializing qualified members in all contexts? We can reuse the same primitive flow analysis that's now used for super(). I think it would be better to have special qualifier for such situation. Anyway we implicitly have it. Problem with flow analysis is that callee may have no idea who is caller due to separate compilation. I disagree. A new qualifier would complicate the language much more than a typechecking rule for constructors. BTW the raw/cooked design is proven - it's been already used in a number of papers and languages. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #15 from Maxim Fomin ma...@maxim-fomin.ru 2013-03-10 13:16:15 PDT --- (In reply to comment #14) (In reply to comment #13) (In reply to comment #9) This is an insufficiency in D's design. I think we should approach this the same way as super() invocation and construction of qualified objects This is close to const vs postblit problem. The problem appeared due to unthoughtful decision to allow const objects mutation during construction. But it is too late now. I disagree it's too late, seeing as I actually propose a solution. Also, this is probably not the best forum to air criticisms about the competence and state of mind of the language designers. The purpose was not to insult language designers but to point that affecting one feature may break its interaction with other features. By the way, what is about example in comment 1 when non-const opAssign stores mutable pointer to immutable data? I'm not sure what you mean. What about it? This can't occur in the proposed raw/cooked design. From what I understood, the proposal is to relax(remove temporarily) constness of members during ctor invocation which allows code like below: T* p; struct T { void opAssign(int n) { ...; p = this; } } struct S { immutable T field; this(...) { field = 1; // invoke T.opAssign (currently not allowed) /* now global p holds mutable pointer to immutable T object! */ } } Or I misunderstood completely and you really proposing to call something like super(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 Kenji Hara k.hara...@gmail.com changed: What|Removed |Added AssignedTo|nob...@puremagic.com|and...@erdani.com --- Comment #1 from Kenji Hara k.hara...@gmail.com 2013-03-09 08:01:49 PST --- This is unfixable problem, if I'm not mistaken. Currently, compiler always considers opAssign operator overloading for all field assignment in constructor. struct S { T field; this(...) { field = xxx; } // If T has opAssign, it is called. } But for non-mutable field, opAssign invocation is not legal, because it may break const correctness. T* p; struct T { void opAssign(int n) { ...; p = this; } } struct S { immutable T field; this(...) { field = 1; // invoke T.opAssign (currently not allowed) /* now global p holds mutable pointer to immutable T object! */ } } I have no answer for this issue... So, assigned to Andrei. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 Andrej Mitrovic andrej.mitrov...@gmail.com changed: What|Removed |Added CC||andrej.mitrov...@gmail.com --- Comment #2 from Andrej Mitrovic andrej.mitrov...@gmail.com 2013-03-09 09:07:15 PST --- (In reply to comment #1) This is unfixable problem, if I'm not mistaken. What if opAssign is const/inout? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #3 from Kenji Hara k.hara...@gmail.com 2013-03-09 09:14:18 PST --- (In reply to comment #2) (In reply to comment #1) This is unfixable problem, if I'm not mistaken. What if opAssign is const/inout? It would be invoked, but you cannot do any meaningful operation in it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #6 from Maksim Zholudev maxim...@gmail.com 2013-03-09 09:47:58 PST --- (In reply to comment #1) But for non-mutable field, opAssign invocation is not legal, because it may break const correctness. T* p; struct T { void opAssign(int n) { ...; p = this; } } struct S { immutable T field; this(...) { field = 1; // invoke T.opAssign (currently not allowed) /* now global p holds mutable pointer to immutable T object! */ } } Is there any way to break const correctness if opAssign is pure? If not, then changes should be allowed for pure opAssign (e.g. with implicit cast field to mutable). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #7 from Kenji Hara k.hara...@gmail.com 2013-03-09 10:29:11 PST --- (In reply to comment #5) [snip] To enforce breaking type system by language users is not good at all. When talking about language semantics, unsafe operation like cast must not appear. Language user can break type system explicitly, but compiler must not do it. (In reply to comment #6) Is there any way to break const correctness if opAssign is pure? 'pure' attribute does not affect constancy. If not, then changes should be allowed for pure opAssign (e.g. with implicit cast field to mutable). opAssign should modify its 'this' object for the meaningful operation, but mutable method cannot call on non-const object, even inside constructor. So this problem is unfixable. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 Andrei Alexandrescu and...@erdani.com changed: What|Removed |Added CC||and...@erdani.com --- Comment #10 from Andrei Alexandrescu and...@erdani.com 2013-03-09 17:43:08 PST --- Assigned to Kenji :o). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #9 from Andrei Alexandrescu and...@erdani.com 2013-03-09 17:42:11 PST --- This is an insufficiency in D's design. I think we should approach this the same way as super() invocation and construction of qualified objects: 1. When a constructor is entered, the object is in a raw state. 2. While in this raw state, the object is not considered initialized so it can't be passed to functions etc. Its const/immutable members (be they by their own qualifier or propagated from the object) are also raw and can't be passed out. 3. This raw state lasts until super() has been called EXACTLY ONCE and each qualified field has been assigned to EXACTLY ONCE. 4. At that point the object has become cooked and all restrictions are lifted. Kenji, I recall we discussed this design in the context of const and immutable constructors, and you were favorable to it. How about we extend the same design for initializing qualified members in all contexts? We can reuse the same primitive flow analysis that's now used for super(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9665] Structure constant members can not be initialized if have opAssign
http://d.puremagic.com/issues/show_bug.cgi?id=9665 --- Comment #12 from Andrei Alexandrescu and...@erdani.com 2013-03-09 18:32:32 PST --- @Kenji: that's exactly right. Just in case it isn't obvious, that only assignment for qualified fields while in raw state is not an opAssign call, it's a constructor call. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---