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.
Comment #1 by k.hara.pg — 2012-05-12T09:19:00Z
Comment #2 by github-bugzilla — 2012-05-28T12:06:23Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/0320e5bd1c96b0731f62dd6d17a726f5b7b734a7 fix Issue 8015 - std.typecons.Tuple does not support struct with alias method this https://github.com/D-Programming-Language/phobos/commit/3115e61d28ee9eab674bb349b69b2671e26dbb93 Merge pull request #576 from 9rnsr/fix8015 Issue 8015 - std.typecons.Tuple does not support struct with alias method this