[Issue 15957] Disabled postblit + template mixin break opAssign with confusing error message

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Apr 28 05:39:56 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15957

--- Comment #6 from Dicebot <public at dicebot.lv> ---
This is rather far from what I'd call "documented somewhere" :) Sorry if this
semantics may seem intuitive to you, but they are in fact highly confusing, at
least with existing error messages. I have spent ~2 hours to simply reduce the
test case (it isn't very dustmite friendly) and wasn't even close to guessing
underlying reason after that.

Your proposed fix works fine for specific code I have but I can't consider it
resolved with existing state of things in general. There is a dire need of
documentation upgrade here.

Some suggestions:

1)

"An opAssign is always generated when there's a postblit, disabled or not,
because opAssign is what the compiler generates a call to when assigning"

This needs to be mentioned at
https://dlang.org/spec/struct.html#struct-postblit (ideally, together with
rationale). The fact that compiler auto-generated assignment when postblit is
present is less surprising, but the fact it is still generated when one
explicitly says to disable it is extremely confusing. What would be the body of
generated opAssign when postblit is disabled?

2) 

"... function wat.S.opAssign (S p) is not callable using argument types
(int[])"

It would be quite helpful for such error messages to mention that relevant
function is not user-defined:

"... auto-generated function wat.S.opAssign (S p) is not callable using
argument types (int[])"

3)

"Mixed in templates are considered imports as far as looking things up goes."

This is contradicts dlang.org documentation:

https://dlang.org/spec/template-mixin.html

"... It is analogous to cutting and pasting the body of the template into the
location of the mixin."

It looks like documentation doesn't match actual intention behind the mixin
semantics and needs to be updated.

--


More information about the Digitalmars-d-bugs mailing list