www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12171] New: Refused UFCS call for a sum()

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

           Summary: Refused UFCS call for a sum()
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



import std.algorithm: sum;
void main() {
    enum int[] arr1 = [10, 20];
    int[arr1.sum] arr2;
}


dmd 2.065beta3 gives:

test.d(4,19): Error: no property 'sum' for type 'int[]'

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12171


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com
            Summary|Refused UFCS call for a     |Parenthesis-less call fails
                   |sum()                       |in static array length
                   |                            |context



Seems unrelated to sum. The same issue happens with any function called UFCS,
without parens. It also happens regardless of input type. For example:

//----
size_t foo(int) {return 1;}
size_t bar() {return 1;}

void main() {
    enum int a = 0;

    enum i = 5.foo; //OK!
    enum j = a.foo; //OK!
    enum k = bar;   //OK!

    int[5.foo] arr1; //OK!
    int[a.foo] arr2; //NOPE
    int[bar  ] arr3; //NOPE
}
//----

The issue appears to simply be that parentless calls in a array-length context
doesn't work? Strangely enough, it works with literals though.

Maybe http://d.puremagic.com/issues/show_bug.cgi?id=11247
Is related?

Changing name.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 27 2014