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: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Kenji Hara <[email protected]> 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: -------

Reply via email to