Bug 18228 – this(this a){} doesn't generate postblit ctor; this(this){} does

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-12T02:34:45Z
Last change time
2018-05-12T13:25:00Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Timothee Cour
See also
https://issues.dlang.org/show_bug.cgi?id=12228

Comments

Comment #0 by timothee.cour2 — 2018-01-12T02:34:45Z
in all of D, parameter names are optional (if unused) eg: `fun(int a)` <=> `fun(int)` but not for postblit: ``` struct C{ version(v1) this(this a){} version(v2) this(this){ } } pragma(msg, "C: " ~ __traits(allMembers, C).stringof); ``` dmd -o- -version=v1 main.d C: tuple("__ctor") dmd -o- -version=v2 main.d C: tuple("__postblit", "__xpostblit", "opAssign") DMD64 D Compiler v2.077.1
Comment #1 by ag0aep6g — 2018-01-12T02:46:03Z
`this(this a){}` is not a postblit function. DMD apparently interprets it as a constructor, same as `this(typeof(this) a) {}`. I don't think that's correct, though. It should be rejected as invalid code. Tagging accordingly.
Comment #2 by timothee.cour2 — 2018-01-12T02:48:20Z
agreed, `this(typeof(this) a) {}` should be the correct syntax
Comment #3 by razvan.nitu1305 — 2018-04-05T12:39:20Z
Comment #4 by github-bugzilla — 2018-04-19T08:04:21Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/5cebe70bd69496f129bf2284b02fbe1cbcbd3b82 Fix Issue 18228 - this(this a){} doesn't generate postblit ctor; this(this){} does https://github.com/dlang/dmd/commit/bbc087e67ea977de2d5f0410d306b510e4baeb92 Merge pull request #8141 from RazvanN7/Issue_18228 Fix Issue 18228 - this(this a){} doesn't generate postblit ctor; this(this){} does merged-on-behalf-of: Jacob Carlborg <[email protected]>
Comment #5 by nick — 2018-05-12T13:22:11Z
*** Issue 9597 has been marked as a duplicate of this issue. ***