[Issue 8138] New: Attribute inference fails with Voldemort type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 23 21:45:40 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8138

           Summary: Attribute inference fails with Voldemort type
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jmdavisProg at gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-05-23 21:47:20 PDT ---
This stripped down code from one of my programs

import std.algorithm;
import std.range;
import std.traits;


void main()
{
    ubyte[] buffer = [1, 2, 9, 7, 6];
    auto filtered = filter!"true"(buffer);
    auto br2 = bitReader(filtered);
}

final class BitReader(R)
    if(isInputRange!R && is(ElementType!R : const ubyte))
{
    this(R)(R bytes)
    {
        _bytes = bytes;
    }


    @property bool empty() const
    {
        return _bytes.empty;
    }


    R _bytes;
}

BitReader!R bitReader(R)(R r)
    if(isInputRange!R && is(ElementType!R : const ubyte))
{
    return new BitReader!R(r);
}


results in this compilation error:

q.d(24): Error: function
std.algorithm.filter!("true").filter!(ubyte[]).filter.Result.empty () is not
callable using argument types (


If empty is changed to mutable, the code compiles just fine, but if it's either
 const or inout, it fails. Given that the empty that filter's Result's empty is
calling is std.array.empty (whose parameter is in), filter's Result's empty
should be inferred as const, but it appears that it's not, since my class'
empty can't be const due to the call to filter's Result's empty.

My _guess_ would be that the problem stems from the fact that Result isn't
templated (rather filter is templated, and Result is generated as part of that
template), but I don't know. Regarldess, this is a major problem for constness
and Voldemort types.

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


More information about the Digitalmars-d-bugs mailing list