www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4525] New: Array member call syntax can't find matches in current class

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4525

           Summary: Array member call syntax can't find matches in current
                    class
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: cbkbbejeap mailinator.com


--- Comment #0 from Nick Sabalausky <cbkbbejeap mailinator.com> 2010-07-28
12:44:54 PDT ---
This works fine in 1.062, but fails in 2.047 (has also been tested to fail in
2.042, 2.046):

module mymodule;
class Foo
{
    void bar(string s) {}

    void foo()
    {
        string str = "hello";
        str.bar();
    }
}

Compiler output for 2.047:

mymodule.d(9): Error: undefined identifier module mymodule.bar

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 28 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4525


Nick Sabalausky <cbkbbejeap mailinator.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression


--- Comment #1 from Nick Sabalausky <cbkbbejeap mailinator.com> 2010-07-28
12:47:37 PDT ---
Don has reported that "It worked in 2.012 and earlier, but failed in 2.020. I
don't have any intermediate versions installed."

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 28 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4525



--- Comment #2 from Nick Sabalausky <cbkbbejeap mailinator.com> 2010-07-29
13:37:35 PDT ---
I've investigated a little further:

2.019 works and 2.020 fails. So the regression was introduced in 2.020.

Maybe it's related to fix for this?:
http://d.puremagic.com/issues/show_bug.cgi?id=2344

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 29 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4525


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2012-01-31
22:19:13 PST ---
I can confirm it works in D1 and fails on D2.

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


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #4 from yebblies <yebblies gmail.com> 2012-02-01 17:27:08 EST ---
This was introduced quite intentionally in
https://github.com/D-Programming-Language/dmd/commit/f87c229d74e02f7f6d9522068ce80b1bbcd1c3db
in order to fix issue 2344.

I tried to fix it, but got a lot of weird crashes in the glue layer.

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


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2012-01-31
22:32:42 PST ---
Further investigation shows that this is not a bug.

    array.func(arguments)

is rewritten to be:

    .func(array, arguments)

Note the leading ., which means look for func() at module scope. Foo.bar() in
the example is not at module scope, hence it is not found. Note that the error
message gives the clue in referring to "mymodule.bar", not just "bar".

This was a deliberate design choice, as universal function call syntax is a
feature meant to be used with global functions, not local ones.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


--- Comment #6 from Kenji Hara <k.hara.pg gmail.com> 2012-01-31 22:51:48 PST ---
(In reply to comment #5)
 Further investigation shows that this is not a bug.
 
     array.func(arguments)
 
 is rewritten to be:
 
     .func(array, arguments)
 
 Note the leading ., which means look for func() at module scope. Foo.bar() in
 the example is not at module scope, hence it is not found. Note that the error
 message gives the clue in referring to "mymodule.bar", not just "bar".
 
 This was a deliberate design choice, as universal function call syntax is a
 feature meant to be used with global functions, not local ones.
The original bug issue against paired the change is bug 2344. But finding UFCS property/member function from global scope causes problems like this issue. And the finding rule is not work against function local import, see bug 6185. My suggestion is here: http://d.puremagic.com/issues/show_bug.cgi?id=6185#c6 - The UFCS lookup should start *from most inside scope*, not module scope. - Until reaching to module scope, UFCS lookup should not raise errors against mismatches of invalid function call, instead *ignore* them silently. - Finally, if there is no match in all scopes, raise an error. -- 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=4525


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |DUPLICATE
           Severity|regression                  |enhancement


--- Comment #7 from Walter Bright <bugzilla digitalmars.com> 2012-01-31
23:14:13 PST ---
Since the current behavior matches the spec, redesigning the behavior would be
an enhancement request. This makes it a duplicate of bug 6185.

*** This issue has been marked as a duplicate of issue 6185 ***

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


yebblies <yebblies gmail.com> changed:

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


--- Comment #8 from yebblies <yebblies gmail.com> 2012-02-02 17:23:40 EST ---
*** Issue 5567 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