www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11401] New: ElementType returns constructor instead of type

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11401

           Summary: ElementType returns constructor instead of type
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jcrapuchettes gmail.com



09:42:06 PDT ---
Using latest git HEAD, the following code produces an error where 2.063.2 does
not. It appears to be a problem with either std.range.ElementType or
std.traits.lvalueOf.

Code
---
import std.range;

void main()
{
    alias ElementType!RowRange E;
    static assert(is(typeof(E.id)), E.stringof~" is expected to have a 'id'
member");
}

struct RowRange
{
    BasicNode front()
    {
        return BasicNode.init;
    }
}

struct BasicNode { ushort id; }

Output
---
$ ~/dmd-git/build/bin/dmd serialize.d
test.d(6): Error: static assert  "BasicNode() is expected to have a 'id'
member"

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 31 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11401


Andrei Alexandrescu <andrei erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei erdani.com



PST ---
Turns out it's a compiler bug, not a library one. I reduced the code to:

struct RowRange
{
    BasicNode front()
    {
        return BasicNode.init;
    }
}

struct BasicNode { ushort id; }

void main()
{
    alias E1 = typeof(RowRange.init.front());
    static assert(is(typeof(E1.id)),
        E1.stringof~" is expected to have a 'id' member");
    alias E2 = typeof(RowRange.init.front);
    static assert(is(typeof(E2.id)),
        E2.stringof~" is expected to have a 'id' member");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11401




This is git-head only issue.

Introduced by:
https://github.com/D-Programming-Language/phobos/pull/1658


     alias E1 = typeof(RowRange.init.front());
     static assert(is(typeof(E1.id)),
         E1.stringof~" is expected to have a 'id' member");
     alias E2 = typeof(RowRange.init.front);
     static assert(is(typeof(E2.id)),
         E2.stringof~" is expected to have a 'id' member");
Currently typeof(non_property_func) returns the function type, not its return type. It is intended behavior, and this is not a compiler issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11401


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

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



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11401




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/a9eb6219b4d03ace4e6688eaeb3dfcd4f90a9faf
fix Issue 11401 - ElementType returns constructor instead of type

1. For `exp.member`, compiler always try to resolve property/optional
parenthesis on `exp`. so use `front.init`.
2. Built-in `init` property always returns rvalue, so `front.init` won't invoke
postblit.

https://github.com/D-Programming-Language/phobos/commit/d743e6caa9c52e53f6bac38fb925d46b65071f78


[REG2.065a] Issue 11401 - ElementType returns constructor instead of type

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11401


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: -------
Nov 04 2013