August 21, 2006 [Issue 301] New: Lazy Delegate Evaluation messes with writefln | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=301 Summary: Lazy Delegate Evaluation messes with writefln Product: D Version: 0.165 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: ddparnell@bigpond.com The following compiles but the output is wrong. // ---------- TEST FILE --------- import std.stdio; bool scase(bool b, void delegate() dg) { if (b) { dg(); return true; } return false; } void cond(bool delegate()[] cases ...) { foreach (c; cases) { if (c()) break; } } void foo() { int v = 2; cond ( scase(v == 1, {writefln("it is 1");}), scase(v == 2, {writefln("it is 2");}), scase(v == 3, {writefln("it is 3");}), scase(true, {writefln("it is the default");}) ); } void main() { foo(); } // ---------- END OF TEST FILE --------- The output is ... "[char[]]it is 2" instead of the expected ... "it is 2" -- |
September 03, 2006 [Issue 301] Lazy Delegate Evaluation messes with writefln | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=301 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #1 from bugzilla@digitalmars.com 2006-09-02 19:45 ------- Fixed 0.166 -- |
Copyright © 1999-2021 by the D Language Foundation