digitalmars.D.bugs - [Issue 17445] New: Disagreement between 'static assert' and 'static
- via Digitalmars-d-bugs (28/28) May 27 2017 https://issues.dlang.org/show_bug.cgi?id=17445
https://issues.dlang.org/show_bug.cgi?id=17445 Issue ID: 17445 Summary: Disagreement between 'static assert' and 'static if' Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dario.schiavon gmail.com Using DMD32 v2.074.0. struct MyStruct { static assert(is(typeof(this = this))); // Here it passes. static if (!is(typeof(this = this))) static assert(0); // But here it fails. } If the is-expression was true in the assertion, how can it be false in the static-if condition? Notwithstanding the fact that, AFAIK, 'this' in this context (outside of a member function) shouldn't be defined. It compiles without errors with LDC2 v1.1.1 (which is based on DMD v2.071.2). The reason I wrote this code is I need to check whether the postblit constructor is defined (or alternatively opAssign) before I define a member function that makes use of it. --
May 27 2017