Bug 11914 – Missed tuple unpacking in foreach for cartesianProduct
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-13T04:55:00Z
Last change time
2014-01-14T13:19:58Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2014-01-13T04:55:25Z
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).