[Issue 17426] "version(none):" cant be overwritten by its counterpart

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed May 24 05:54:00 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17426

Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |thecybershadow at gmail.com
         Resolution|---                         |WONTFIX

--- Comment #1 from Vladimir Panteleev <thecybershadow at gmail.com> ---
The rule being followed here is:

{
version(x):
...code...
}

is equivalent to

{
version(x)
{...code...}
}

i.e. everything is wrapped until the end of the current scope, or file if at
the top level.

Thus, your code is equivalent to:

version(none)
{
  unittest {assert(false);}
  version(all)
  {
    unittest {assert(false);} // not compiled
    version(none)
    {
      unittest {assert(false);}
    }
  }
}

Making your code work as intuitively expected would mean breaking consistency
with the rule (though adding a warning for this to either DMD or DScanner might
not be a bad idea).

--


More information about the Digitalmars-d-bugs mailing list