View mode: basic / threaded / horizontal-split · Log in · Help
June 20, 2011
[Issue 6185] New: UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185

          Summary: UFCS doesn't work with function imports
          Product: D
          Version: D2
         Platform: Other
       OS/Version: Windows
           Status: NEW
         Severity: normal
         Priority: P2
        Component: DMD
       AssignedTo: nobody@puremagic.com
       ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-06-20 15:55:20 PDT ---
Note: Function imports is a new feature that's currently in DMD's github repo,
it's not in 2.053, but it's going to be in 2.054.

module test;
void main()
{
}

void foo()
{
  import std.utf;
  "foo".toUTF16z;
}

Error: undefined identifier module test.toUTF16z

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185


bearophile_hugs@eml.cc changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2012-01-21 19:41:29 PST ---
*** Issue 7344 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: -------
January 22, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-22 05:30:13 PST ---
Before 2.053, "foo".toUTF16z is rewritten to toUTF16("foo");
After 2.054, it is rewitten to .toUTF16("foo");
Therefore current D2 requires module level function for UFCS.

But I don't know it is right behavior.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #3 from bearophile_hugs@eml.cc 2012-01-22 07:07:32 PST ---
(In reply to comment #2)
> Before 2.053, "foo".toUTF16z is rewritten to toUTF16("foo");
> After 2.054, it is rewitten to .toUTF16("foo");

What's bad in rewriting it as toUTF16("foo")?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-22 08:07:51 PST ---
(In reply to comment #3)
> (In reply to comment #2)
> > Before 2.053, "foo".toUTF16z is rewritten to toUTF16("foo");
> > After 2.054, it is rewitten to .toUTF16("foo");
> 
> What's bad in rewriting it as toUTF16("foo")?

Ah, sorry, it is my mistake. Replace 'toUTF16' to 'toUTF16z'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #5 from bearophile_hugs@eml.cc 2012-01-22 09:05:49 PST ---
(In reply to comment #4)

> Ah, sorry, it is my mistake. Replace 'toUTF16' to 'toUTF16z'.

What's bad in rewriting it as toUTF16z("foo")?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 24, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #6 from Kenji Hara <k.hara.pg@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: -------
January 24, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-24 06:01:13 PST ---
(In reply to comment #2)
> Before 2.053, "foo".toUTF16z is rewritten to toUTF16("foo");
> After 2.054, it is rewitten to .toUTF16("foo");
> Therefore current D2 requires module level function for UFCS.
> 
> But I don't know it is right behavior.

Sorry, I had said mistake. The turning point was 2.020, not 2.054.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185


Walter Bright <bugzilla@digitalmars.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |bugzilla@digitalmars.com
          Severity|normal                      |enhancement


--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2012-01-31 23:13:25 PST ---
It currently works as specified, so this is an enhancement request, not a bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2012
[Issue 6185] UFCS doesn't work with function imports
http://d.puremagic.com/issues/show_bug.cgi?id=6185


Walter Bright <bugzilla@digitalmars.com> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |cbkbbejeap@mailinator.com


--- Comment #9 from Walter Bright <bugzilla@digitalmars.com> 2012-01-31 23:14:13 PST ---
*** Issue 4525 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: -------
« First   ‹ Prev
1 2 3
Top | Discussion index | About this forum | D home