Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 02, 2013 [Issue 9628] New: Lambda in foreach loop Vs. lambda in static foreach loop | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9628 Summary: Lambda in foreach loop Vs. lambda in static foreach loop Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-03-01 16:48:17 PST --- This program shows two similar versions of the same loop: import std.stdio, std.algorithm, std.typetuple, std.range; void main() { auto items = [[10, 20], [30]]; foreach (_; 0 .. 2) { foreach (sub; items) { iota(sub.length) .map!((i){ writeln(sub); return 0; }) .array(); } } writeln(); foreach (_; TypeTuple!(0, 1)) { foreach (sub; items) { iota(sub.length) .map!((i){ writeln(sub); return 0; }) .array(); } } } Its output (dmd 2.063alpha): [10, 20] [10, 20] [30] [10, 20] [10, 20] [30] [10, 20] [10, 20] [30] [30] [30] [30] Probably the two loops should give the same output. (Also, this program can't be compiled with -inline). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 02, 2013 [Issue 9628] Lambda in foreach loop Vs. lambda in static foreach loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9628 Maxim Fomin <maxim@maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxim@maxim-fomin.ru --- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-03-02 00:27:30 PST --- Rewritten version (this can be complied with -inline): import std.stdio, std.algorithm, std.typetuple, std.range; auto items = [[10, 20], [30]]; void bar() { foreach (int dx; 0 .. 2) { foreach (sub; items) { iota(sub.length) .map!((size_t i){ writeln(dx,"--", sub,"--", items); return 0; }) .array(); }} } void foo() { foreach (int dx; TypeTuple!(0, 1)) { foreach (sub; items) { iota(sub.length) .map!((size_t i){ writeln(dx,"--", sub,"--", items); return 0; }) .array(); }} } void main() { bar(), writeln(), foo(); } dx in second loop is always zero -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 13, 2013 [Issue 9628] Lambda in foreach loop Vs. lambda in static foreach loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9628 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Platform|x86 |All OS/Version|Windows |All --- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-13 02:39:52 PDT --- https://github.com/D-Programming-Language/dmd/pull/2029 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 08, 2013 [Issue 9628] Lambda in foreach loop Vs. lambda in static foreach loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9628 --- Comment #3 from github-bugzilla@puremagic.com 2013-06-08 01:25:43 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/0ba974c94e61af361aa77756bfdcf4a9353b546f fix Issue 9628 - Lambda in foreach loop Vs. lambda in static foreach loop https://github.com/D-Programming-Language/dmd/commit/a8f842e12154eee7d79c1943f6e3806116cf0525 Merge pull request #2029 from 9rnsr/fix9628 Issue 9628 - Lambda in foreach loop Vs. lambda in static foreach loop -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 08, 2013 [Issue 9628] Lambda in foreach loop Vs. lambda in static foreach loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9628 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 08, 2013 [Issue 9628] Lambda in foreach loop Vs. lambda in static foreach loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9628 --- Comment #4 from bearophile_hugs@eml.cc 2013-06-08 05:25:47 PDT --- The loop can't be compiled with -inline, but the main problem seems fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation