Bug 9073 – In manifest constant initializer, && and || should evaluate their operands lazily.

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-25T00:56:18Z
Last change time
2018-01-02T20:45:06Z
Keywords
pull
Assigned to
No Owner
Creator
Kenji Hara

Comments

Comment #0 by k.hara.pg — 2012-11-25T00:56:18Z
With and without `version=expected`, this code should work, but doesn't. bool foo(alias pred)() { version(expected) { // doesn't work, but should enum isLessThan = (is(typeof(pred) : string) && pred == "a < b"); } else { // works as expected static if (is(typeof(pred) : string) && pred == "a < b") enum isLessThan = true; else enum isLessThan = false; } return isLessThan; } void main() { assert(foo!("a < b")() == true); assert(foo!((a,b) => a<b)() == false); } Manifest constant declaration is always evaluated in compile time, so I think there is no problem.
Comment #1 by k.hara.pg — 2012-11-25T01:11:02Z
Comment #2 by github-bugzilla — 2013-09-09T23:17:46Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3b101f404707fc8a06cec6e547ffb38ea3ef756b fix Issue 9073 - In manifest constant initializer, && and || should evaluate their operands lazily. https://github.com/D-Programming-Language/dmd/commit/c97061421b2a1acd621a13a3ad8853c9d2ee2ffc Merge pull request #1325 from 9rnsr/fix9073 Issue 9073 - In manifest constant initializer, && and || should evaluate their operands lazily.
Comment #3 by bugzilla — 2013-09-10T12:33:48Z
This was reverted due to inadequate specification, unintended side effects, and breaking existing code.
Comment #4 by k.hara.pg — 2013-09-15T04:45:21Z