www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8015] New: std.typecons.Tuple does not support struct with alias method this

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: robert octarineparrot.com



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: -------
May 02 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8015


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid



https://github.com/D-Programming-Language/phobos/pull/576

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8015




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


Issue 8015 - std.typecons.Tuple does not support struct with alias method this

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 28 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8015


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31 2012