[Issue 2344] New: Two wrong lookups for array functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 7 11:33:06 PDT 2008


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

           Summary: Two wrong lookups for array functions
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: andrei at metalanguage.com


size_t blah(int[] r) { return r.length; }

struct A
{
    int[] r;
    size_t blah() { return r.blah(); }
}

void main()
{
    A a;
    a.blah;
}

The code above says:

function test.A.blah () does not match parameter types (int[])
Error: expected 0 arguments, not 1

So it looks like the compiler first morphs r.blah() into blah(r), but then uses
the local scope to look for blah. Therefore A.blah will be found, leading to
the nonsensical call this.blah(r).

Interestingly, if the parens are removed leaving r.blah, the lookup is still
wrong but in a different way:

Error: no property 'blah' for type 'int[]'

So this time the call fails to start with. Both errors are bugs. The code
should compile with and without parentheses.


-- 



More information about the Digitalmars-d-bugs mailing list