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).
Comment #1 by k.hara.pg — 2014-01-13T22:33:18Z
Comment #2 by github-bugzilla — 2014-01-14T13:19:44Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7bbbed54d8fc32c1c538b5cd44a7ac5e45ea610b fix Issue 11914 - Missed tuple unpacking in foreach for cartesianProduct https://github.com/D-Programming-Language/dmd/commit/dce6d8cdbb972e2704ca54d4db15502dd60ea8b8 Merge pull request #3091 from 9rnsr/fix11914 [REG2.065a] Issue 11914 - Missed tuple unpacking in foreach for cartesianProduct