www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8138] New: Attribute inference fails with Voldemort type

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



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


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |blocker



PDT ---
Note that this blocks const-ifying or inout-ifying some stuff in std.range and
std.algorithm, making it harder to make them const-correct.

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


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net



13:42:20 PDT ---
 safe, pure and nothrow aren't inferred in Voldemort types either.

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




PDT ---
 safe, pure and nothrow are supposed to be inferred on all templates, so if
they're not inferred for Voldemort types, and they're templated (as they
usually are), then it's definitely a bug (and I think that there's at least one
open bug on that, but I'm not sure).

But reading over this bug report, I'm not quite sure what I was thinking when I

which might solve this problem, but from what I can tell, there is no bug in
dmd here. Either filter needs to be improved via static ifs, or we need

occuring here, but I don't think that there's an actual compiler bug, and I
don't know why I thought that there was at the time that I reported it.

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


Jonathan M Davis <jmdavisProg gmx.com> changed:

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


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




23:11:19 PDT ---
I've added a new bug report: issue 10329

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