www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9073] New: In manifest constant initializer, && and || should evaluate their operands lazily.

reply d-bugmail puremagic.com writes:
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



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: -------
Nov 25 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9073


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

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



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: -------
Nov 25 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9073




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


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: -------
Sep 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Sep 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9073


Walter Bright <bugzilla digitalmars.com> changed:

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



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: -------
Sep 10 2013
prev sibling parent d-bugmail puremagic.com writes:
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                     |



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: -------
Sep 15 2013