September 04, 2021 [Issue 22278] New: [Conditional Compilation] there should be in and out flags | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22278 Issue ID: 22278 Summary: [Conditional Compilation] there should be in and out flags Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: jlourenco5691@gmail.com Currently, there is no way within the language to check if contracts are being compiled or not. The only way is to use `version(assert)`, which accomplishes that in a way. The problem is if the user runs unit tests in release mode. The assertions are compiled but contracts are not, leading to the failure of all `assertThrown` checks. There are ways to still compile without failures. DMD has the `check` flag that can override the build mode. To run unit tests in release with `in` contracts on, one can pass `-check=in=on` to the compiler. But this still isn't favorable because the flag isn't shared across compilers. LDC for example has `--enable-preconditions=1`. Having a language version can standardize this and make it easier when working with this. I propose implementing the version flags: D_PreConditions and D_PostConditions for `in` and `out` contracts respectively. -- |
Copyright © 1999-2021 by the D Language Foundation