digitalmars.D - why is this flagged as poor style?
- Andrei Alexandrescu (9/9) Sep 22 2020 The style checker for phobos flags this code:
- Steven Schveighoffer (5/19) Sep 22 2020 I think it needs braces (I'd do them for both blocks).
- Brian Schott (4/5) Sep 22 2020 The D-Scanner check that's begin discussed here has a unit test
The style checker for phobos flags this code: static if (!is(typeof(unaryFun!fun(r.front)) == Flag!"each")) cast(void) unaryFun!fun(r.front); else if (unaryFun!fun(r.front) == No.each) return No.each; with "Mismatched static if. Use 'else static if' here." But in fact the intention is to execute a run-time `if` on the `else` branch of the `static if`. Is this worth fixing?
Sep 22 2020
On 9/22/20 5:35 PM, Andrei Alexandrescu wrote:The style checker for phobos flags this code: static if (!is(typeof(unaryFun!fun(r.front)) == Flag!"each")) cast(void) unaryFun!fun(r.front); else if (unaryFun!fun(r.front) == No.each) return No.each; with "Mismatched static if. Use 'else static if' here." But in fact the intention is to execute a run-time `if` on the `else` branch of the `static if`. Is this worth fixing?I think it needs braces (I'd do them for both blocks). When you are mixing static if and if (or version etc.), make it very clear the difference. -Steve
Sep 22 2020
On Tuesday, 22 September 2020 at 21:50:11 UTC, Steven Schveighoffer wrote:I think it needs braces (I'd do them for both blocks).The D-Scanner check that's begin discussed here has a unit test checking that adding braces will silence the warning.
Sep 22 2020