Thread overview
[Issue 10096] New: Regression (git-head): __traits(allMembers) triggers out of bounds error
May 16, 2013
Andrej Mitrovic
May 16, 2013
Kenji Hara
May 16, 2013
Kenji Hara
May 16, 2013
Andrej Mitrovic
May 16, 2013
Andrej Mitrovic
May 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10096

           Summary: Regression (git-head): __traits(allMembers) triggers
                    out of bounds error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-05-16 07:15:21 PDT ---
import std.conv;

string foo(alias var, T = typeof(var))()
{
    foreach (idx, member; __traits(allMembers, T))
    {
        // Error: array index [2] is outside array bounds [0 .. 2]
        to!string(var.tupleof[idx]);
    }

    return "";
}

struct S
{
    int i;
    string s;
}

void main()
{
    S s = S(1, "");
    auto x = foo!s;
}

Worked in 2.062, in 2.063:
> Error: array index [2] is outside array bounds [0 .. 2]

Might be related to Issue 10095

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10096



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-16 09:21:38 PDT ---
*** Issue 10095 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10096


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-16 09:24:36 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2043

By fixing bug 3789, currently compiler generates static member function
__xopEquals for S and its TypeInfo.
My compiler change would remove such internal names from the result of
__traits(allMembers).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10096



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-05-16 10:27:20 PDT ---
(In reply to comment #2)
> https://github.com/D-Programming-Language/dmd/pull/2043
> 
> By fixing bug 3789, currently compiler generates static member function
> __xopEquals for S and its TypeInfo.
> My compiler change would remove such internal names from the result of
> __traits(allMembers).

Ok. Btw, the documentation for allMembers trait states:

"Builtin properties are not included."

And it lists __ctor, __dtor *if* they're user-defined (__ctor is not shown if a user doesn't write a constructor).

So I partially think Issue 10097 might be unnecessary, __xopEquals is internal, but __ctor is not since it's only shown if it's user-defined.

Still, I would like to see Issue 10097 fixed, but I'm afraid we might break a lot of code?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10096



--- Comment #4 from github-bugzilla@puremagic.com 2013-05-16 16:23:30 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6ae4b48a10602fbcc1c4c8e07bc12c00b82ba15b fix Issue 10096 - __traits(allMembers) triggers out of bounds error

Internal member names should not be listed in __traits(allMembers)
- Names starting double underscore does not appear its result.
  __cpctor, __invariant, __xopEquals, __fieldPostBlit,
  __aggrPostBlit, __fieldDtor, __aggrDtor, and others...
- Except __ctor, __dtor, and __postblit. They are already used in Phobos, so
  temporary keep them for backward compatibility.

https://github.com/D-Programming-Language/dmd/commit/d714fb15993e8b03a5588ec3cafeecd366375210 Merge pull request #2043 from 9rnsr/fix10096

[REG2.063a] Issue 10096 - __traits(allMembers) triggers out of bounds error

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10096


Andrej Mitrovic <andrej.mitrovich@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: -------