www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9604] New: Element type of std.range.chain is wrong for heterogeneous range arguments

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

           Summary: Element type of std.range.chain is wrong for
                    heterogeneous range arguments
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jakobovrum gmail.com



---
---
import std.range;

void main()
{
    immutable(ubyte)[] imm;
    ubyte[] mut;

    auto c = chain(imm, mut);

    pragma(msg, ElementType!(typeof(c)));
}
---
Output:
---
int
---

As far as I can tell, the element type should be some permutation of ubyte,
like const(ubyte), not int.

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com
          Component|Phobos                      |DMD
            Summary|Element type of             |typeof emits wrong common
                   |std.range.chain is wrong    |type with immutable type
                   |for heterogeneous range     |
                   |arguments                   |



15:40:17 PST ---
The problem is shown when using CommonType:

import std.traits;
import std.typetuple;

void main()
{
    alias TypeTuple!(immutable(ubyte), ubyte) T;
    pragma(msg, CommonType!T);  // int
}

This is a compiler bug. Test-case:

void main()
{
    alias IB = immutable(byte);
    pragma(msg, typeof(true ? byte.init : byte.init)); // byte
    pragma(msg, typeof(true ? IB.init : byte.init));   // int
}

Also another parser bug was found (I'll file this separately):

void main()
{
    auto x = immutable(byte).init;
}

test.d(3): Error: (arguments) expected following immutable(byte)
test.d(3): Error: semicolon expected following auto declaration, not '.'

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




15:42:57 PST ---

 Also another parser bug was found (I'll file this separately):
Filed as Issue 9613. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 27 2013