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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 25 00:56:20 PST 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 at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at 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: -------


More information about the Digitalmars-d-bugs mailing list