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



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



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




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





 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






 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






 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






 
 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





 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



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



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



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



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



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



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



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



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






 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




---


 
 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






 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




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