Summary: Incorrect error message with pointer to ubyte[] and
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Jonathan M Davis <> 2012-06-09 02:21:47 
PDT ---
This code

import std.array;

struct S(R)
    this(R* range)
        _range = range;

    auto front()
        return _range.front;

    R* _range;

void main()
    ubyte[] buffer = [42];
    auto s = S!(ubyte[])(&buffer);
    auto f = s.front;

results in this error:

q.d(12): Error: no property 'front' for type 'ubyte[]'
q.d(21): Error: template instance q.S!(ubyte[]) error instantiating

I'm tempted to argue that this should just compile, since . automatically
dereferences the type that it's on if it's a pointer, and the type in question
(ubyte[]) has a front via std.array, but _range itself doesn't match front's
parameters, because it's a pointer to a ubyte[] rather than a ubyte[], so I
suspect that this _isn't_ supposed to work much as I'd like it to. If it _is_
supposed to work, however, then this obviously shows that it isn't currently
and is therefore a bug.

Regardless of the correct behavior, however, the error message is bad. It says
that ubyte[] has no property front, which is not only not true, but the type
which is failing is ubyte[]*, not ubyte[], so the type in the error message is

Either this code needs to be fixed so that it compiles and works just fine
(automatically dereferencing the pointer and using the type of the dereferenced
pointer rather than the pointer itself when lookin for functions to use with
UFCS), or the error needs to be fixed so that it gives the correct type.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to