[Issue 11914] New: Missed tuple unpacking in foreach for cartesianProduct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 13 04:55:28 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11914

           Summary: Missed tuple unpacking in foreach for cartesianProduct
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2014-01-13 04:55:25 PST ---
This program compiles:


void main() {
    import std.algorithm: cartesianProduct;
    foreach (ijk; cartesianProduct([1], [1], [1])) {}
}


This doesn't compile, but it used to compile:

void main() {
    import std.algorithm: cartesianProduct;
    foreach (i, j, k; cartesianProduct([1], [1], [1])) {}
}


dmd 2.065alpha gives:

test.d(3): Error: cannot infer argument types



If I add both it compiles again:

void main() {
    import std.algorithm: cartesianProduct;
    foreach (ijk; cartesianProduct([1], [1], [1])) {}
    foreach (i, j, k; cartesianProduct([1], [1], [1])) {}
}



(Generally I think this tuple unpacking is a misfeature of D and should be
removed, and replaced by a better and more general solution. But if we want to
remove this feature, it should go through a deprecation path, and not break
randomly as here. So I have marked this as regression).

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


More information about the Digitalmars-d-bugs mailing list