www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6185] New: UFCS doesn't work with function imports

reply d-bugmail puremagic.com writes:
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: -------
Jun 20 2011
next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 31 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Jan 31 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |puneet coverify.org


--- Comment #10 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-27
09:03:02 PST ---
*** Issue 9216 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: -------
Dec 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.97all gmail.com


--- Comment #11 from yebblies <yebblies gmail.com> 2013-01-02 19:34:52 EST ---
*** Issue 8692 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: -------
Jan 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stasoid yahoo.com


--- Comment #12 from yebblies <yebblies gmail.com> 2013-01-02 19:35:09 EST ---
*** Issue 8834 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: -------
Jan 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185


Dicebot <m.strashun gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m.strashun gmail.com


--- Comment #13 from Dicebot <m.strashun gmail.com> 2013-01-26 14:49:51 PST ---
Is it possible to get "preapproved" on this?
Quite inconvenient to add global imports only to use UFCS.

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com


--- Comment #14 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-02-15
08:19:03 PST ---
*** Issue 9515 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 15 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #15 from Kenji Hara <k.hara.pg gmail.com> 2013-04-24 21:52:30 PDT
---
https://github.com/D-Programming-Language/dmd/pull/1930

By the compiler change, this code

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

Would be changed to valid, but

// from issue 4525
class Foo
{
    void bar(string s) {}
    void foo()
    {
        string str = "hello";
        str.bar();
    }
}

Would be kept invalid. Issue 8692, issue 8834, and issue 9515 are same.

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



--- Comment #16 from bearophile_hugs eml.cc 2013-04-25 04:38:11 PDT ---
(In reply to comment #15)

 but
 
 // from issue 4525
 class Foo
 {
     void bar(string s) {}
     void foo()
     {
         string str = "hello";
         str.bar();
     }
 }
 
 Would be kept invalid.

Is this a temporary limit or is this meant to remain as a permanent D wart? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #17 from Kenji Hara <k.hara.pg gmail.com> 2013-04-25 05:11:28 PDT
---
(In reply to comment #16)
 (In reply to comment #15)
 
 but
 
 // from issue 4525
 class Foo
 {
     void bar(string s) {}
     void foo()
     {
         string str = "hello";
         str.bar();
     }
 }
 
 Would be kept invalid.

Is this a temporary limit or is this meant to remain as a permanent D wart?

I think it would be never allowed. It would re-open the bug 2344. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #18 from bearophile_hugs eml.cc 2013-04-25 05:55:14 PDT ---
(In reply to comment #17)

 I think it would be never allowed. It would re-open the bug 2344.

OK. I think that probably there is a way to solve those problems. But I also think that to solve them you probably have to introduce complex rules with corner cases (see C++ templates). So probably a small wart in a simpler language is better that a complex feature that almost works. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6185



--- Comment #19 from github-bugzilla puremagic.com 2013-05-06 00:39:38 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/bb8b47d9168fde3c258eeb0d30a8b5e93ff9c684
fix Issue 6185 - Include non-global functions when resolving UFCS

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


Walter Bright <bugzilla digitalmars.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2013