Bug 8015 – std.typecons.Tuple does not support struct with alias method this
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-02T07:17:00Z
Last change time
2012-05-31T04:08:43Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
robert
Comments
Comment #0 by robert — 2012-05-02T07:17:09Z
The following code:
----
import std.typecons;
struct MyStruct {
string str;
string toStr() {
return str;
}
alias toStr this;
}
void main() {
Tuple!(MyStruct) t;
}
----
Gives the following errors:
----
std/utf.d(558): Error: undefined identifier 'length'
std/utf.d(566): Error: no [] operator overload for type const(MyStruct)
std/utf.d(567): Error: no [] operator overload for type const(MyStruct)
std/utf.d(569): Error: undefined identifier 'ptr', did you mean 'template put(R,E)'?
std/utf.d(569): Error: undefined identifier 'length'
std/utf.d(569): Error: function std.utf.decodeImpl (const(char)* pstr, ulong length, ref ulong index) is not callable using argument types (_error_,_error_,ulong)
std/utf.d(569): Error: expected 2 arguments, not 3 for non-variadic function type pure @safe dchar(const(dchar[]) str, ref ulong index)
std/format.d(1935): Error: template instance std.utf.decode!(MyStruct) error instantiating
std/typecons.d(515): instantiated from here: formatElement!(Appender!(string),MyStruct,char)
test.d(12): instantiated from here: Tuple!(MyStruct)
std/typecons.d(515): Error: template instance std.format.formatElement!(Appender!(string),MyStruct,char) error instantiating
test.d(12): instantiated from here: Tuple!(MyStruct)
test.d(12): Error: template instance std.typecons.Tuple!(MyStruct) error instantiating
----
When compiling with dmd 2.059. If the alias this is changed to use str instead of toStr this works without error.