[Issue 8213] New: Incorrect error message with pointer to ubyte[] and front
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 9 02:19:48 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8213
Summary: Incorrect error message with pointer to ubyte[] and
front
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
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-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
wrong.
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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list