Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
June 28, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> --- Note: Walter is against issuing warnings. The compiler should either accept or reject your code. A warning is something vague that programmers usually ignore (against what best practices advice). In the last 7 years there were exactly 0 warning added to the compiler. With that being said, there is no way such code is ever going to be an error. That would mean that any function that receives an out parameter (or a pointer/ref parameter) would have to issue an error if used in an assert. That is very restrictive. Even if it were issued as a measly warning, I don't really see the usefulness of it. Asserts have the purpose to test for a specific condition, in this particular case, that a function returns a specific value. Why would a warning be issued if a function receives a pointer parameter? What's the actionable item for this message? Stop using the assert? -- |
June 28, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 --- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> --- This could be implemented by a third party tool using dmd as a library. But I don't think it should be implemented in the compiler. -- |
June 28, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@geany.org --- Comment #3 from Nick Treleaven <nick@geany.org> --- Also asserts are used in unit tests where having side effects is often deliberate. -- |
June 28, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 mhh <maxhaton@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxhaton@gmail.com --- Comment #4 from mhh <maxhaton@gmail.com> --- Pretty sure warnings have been added. -- |
June 28, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 Tim <tim.dlang@t-online.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tim.dlang@t-online.de --- Comment #5 from Tim <tim.dlang@t-online.de> --- This seems to be a duplicate of issue 12028. -- |
June 29, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |b2.temp@gmx.com Resolution|--- |DUPLICATE --- Comment #6 from Basile-z <b2.temp@gmx.com> --- *** This issue has been marked as a duplicate of issue 12028 *** -- |
June 29, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 --- Comment #7 from Grim Maple <grimmaple95@gmail.com> --- With all due respect, this isn't a _duplicate_ of 12028. I'm not proposing to disallow side effects, I'm proposing to notify user that their code was not compiled. I think this warning should be issued in release builds only, as they are the only one affected. This will not affect unittests or bring other inconveniences. Besides, maybe, rewriting code from `assert(foo())` to `auto tmp = foo(); assert(tmp);` -- |
June 29, 2023 [Issue 24021] Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|DUPLICATE |--- --- Comment #8 from Basile-z <b2.temp@gmx.com> --- indeed, subtle difference. -- |
Copyright © 1999-2021 by the D Language Foundation