[Issue 11042] New: Inconsistent "static condition" behaviors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 15 04:27:05 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11042

           Summary: Inconsistent "static condition" behaviors
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid, rejects-valid
          Severity: normal
          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> 2013-09-15 04:27:03 PDT ---
Inside static if condition, the logical operators || and && will be evaluated
lazily.

  static if (true || error) { pragma(msg, "OK"); }
  else                      { pragma(msg, "NG"); }
  // --> prints "OK"

This is useful feature, but it doesn't work on static assert condition.

  static assert(true || error);
  // --> Error: undefined identifier error

This is inconsistent. I think static assert should also evaluate the condition
lazily.

----

There's one associated bug.

  static if (is(typeof(true || error))) { pragma(msg, "OK"); }
  else                                  { pragma(msg, "NG"); }
  // --> prints "OK"

The expression "true || error" should not have valid type, but inside static if
condition, the lazy evaluation is incorrectly invoked. It's definitely a bug.

----

Template constraint is the one another place for "static condition".
Currently it behaves like "static if" condition. Its behavior should also be
fixed.

-- 
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