Thread overview
[Issue 9073] New: In manifest constant initializer, && and || should evaluate their operands lazily.
Nov 25, 2012
Kenji Hara
Nov 25, 2012
Kenji Hara
Sep 10, 2013
Walter Bright
Sep 10, 2013
Walter Bright
Sep 15, 2013
Kenji Hara
November 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9073

           Summary: In manifest constant initializer, && and || should
                    evaluate their operands lazily.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2012-11-25 00:56:18 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9073


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-11-25 01:11:02 PST ---
https://github.com/D-Programming-Language/dmd/pull/1325

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9073



--- Comment #2 from github-bugzilla@puremagic.com 2013-09-09 23:17:46 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9073


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9073


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WONTFIX


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2013-09-10 12:33:48 PDT ---
This was reverted due to inadequate specification, unintended side effects, and breaking existing code.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 15, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9073


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |


--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2013-09-15 04:45:21 PDT ---
Retry: https://github.com/D-Programming-Language/dmd/pull/2559

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------