[Issue 6185] UFCS doesn't work with function imports

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 24 05:58:35 PST 2012


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



--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> 2012-01-24 05:58:30 PST ---
(In reply to comment #5)
> (In reply to comment #4)
> 
> > Ah, sorry, it is my mistake. Replace 'toUTF16' to 'toUTF16z'.
> 
> What's bad in rewriting it as toUTF16z("foo")?

I found an original issue and commit revision.

- Issue 2344 - Two wrong lookups for array functions
  Posted by Andrei, and Walter added a fix in dmd 2.020.

- https://github.com/D-Programming-Language/dmd/commit/f87c229d#L7L5774
  Changed the conversion result of array.id(args) into
    from id(array,args)
    to   .id(array,args)

I think that Walter's fix was not enough. UFCS lookup should search *innermost
and valid* function, and in the lookup process, invalid matches should be
ignored.

>From issue 2344:
----
size_t blah(int[] r) { return r.length; }

struct A
{
    int[] r;
    size_t blah() { return r.blah(); }
    // try A.blah(r) -> it is invalid, so should be ignored.
    // try .blah(r)  -> it is valid, so UFCS lookup should match this.
}
void main()
{
    A a;
    a.blah;
}
----

This strategy also work for function local imports.

-- 
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