www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2344] New: Two wrong lookups for array functions

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


-- 
Sep 07 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2344






This is an enhancement. Rewriting:
   array.foo
as:
   .foo(array)
rather than:
   foo(array)
does the trick.


-- 
Oct 10 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2344


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement




-- 
Oct 10 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2344







 This is an enhancement. Rewriting:
    array.foo
 as:
    .foo(array)
 rather than:
    foo(array)
 does the trick.
 
Nah. The whole point was to have obj.foo work for arrays and other beasts. --
Oct 10 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2344


bugzilla digitalmars.com changed:

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





Fixed dmd 2.020


-- 
Oct 20 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2344


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wbaxter gmail.com



*** Issue 1457 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2012