digitalmars.D.bugs - [Issue 18087] New: "no property 'value' for type 'void'" when
- d-bugmail puremagic.com (54/54) Dec 16 2017 https://issues.dlang.org/show_bug.cgi?id=18087
https://issues.dlang.org/show_bug.cgi?id=18087 Issue ID: 18087 Summary: "no property 'value' for type 'void'" when properties split among mixins Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: jonathan wilbur.space I found what I believe is a bug in the way that Dlang deals with template mixins containing properties. The short story is: if you split the getter and setter between two mixin templates, and if the got/set thing is a class (presumably it would work for a struct too), and you try to retrieve a member of that class (or struct) you get the error: no property '???' for type 'void' where '???' is the name of the member you attempted to access. It's hard to explain, but here is my example below: class Box { uint value = 5; } mixin template tempy1() { public property void points (Box p) { this._points = p; } // } // mixin template tempy2() // { public property Box points () { return this._points; } } class Foo { private Box _points; mixin tempy1; // mixin tempy2; unittest { assert((new Foo()).points.value == 5); } } Pardon the compression. With all of the comments in place, this compiles just fine, but remove all of the comments, and you'll see the error message described above. Note, again, that this problem only occurs when the get/set thing is a class (again, maybe a struct too). Maybe there is a little quirk about properties that I have missed, but I reviewed the documentation on properties, and it does not seem like this should happen. Strangely, it seems like removing the setter makes the above compile, even without the comments. --
Dec 16 2017