[Issue 8015] New: std.typecons.Tuple does not support struct with alias method this
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 2 07:15:58 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8015
Summary: std.typecons.Tuple does not support struct with alias
method this
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: robert at octarineparrot.com
--- Comment #0 from Robert Clipsham <robert at octarineparrot.com> 2012-05-02 15:17:09 BST ---
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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list