www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8213] New: Incorrect error message with pointer to ubyte[] and front

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



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


Denis Shelomovskij <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg gmail.com



12:25:44 MSD ---
See also Issue 8245 (probably, one can say it's a dup).

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




14:22:59 MSD ---
The error gives the correct type now:
---
main.d(12): Error: template std.array.front does not match any function
template declaration. Candidates are:
<phobos path>\std\array.d(584):        std.array.front(T)(T[] a) if
(!isNarrowString!(T[]) && !is(T[] == void[]))
<phobos path>\std\array.d(605):        std.array.front(T)(T[] a) if
(isNarrowString!(T[]))
<phobos path>\std\array.d(584): Error: template std.array.front cannot deduce
template function from argument types !()(ubyte[]*)
main.d(21): Error: template instance main.S!(ubyte[]) error instantiating
main.d(22): Error: not a property s.front
---

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


Kenji Hara <k.hara.pg gmail.com> changed:

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




 The error gives the correct type now:
 ---
 main.d(12): Error: template std.array.front does not match any function
 template declaration. Candidates are:
 <phobos path>\std\array.d(584):        std.array.front(T)(T[] a) if
 (!isNarrowString!(T[]) && !is(T[] == void[]))
 <phobos path>\std\array.d(605):        std.array.front(T)(T[] a) if
 (isNarrowString!(T[]))
 <phobos path>\std\array.d(584): Error: template std.array.front cannot deduce
 template function from argument types !()(ubyte[]*)
 main.d(21): Error: template instance main.S!(ubyte[]) error instantiating
 main.d(22): Error: not a property s.front
 ---
In 2.063a, error message with UFCS issues are got fixed. So I'll close this. Currently automatic pointer dereference is not supported in UFCS name look up. For the issue, I'll mark issue 8597 as enhancement. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 24 2013