March 24, 2020 [Issue 3572] declaring pure function with void return type should be compile time error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=3572 Dennis <dkorpel@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED CC| |dkorpel@live.nl Resolution|--- |INVALID --- Comment #9 from Dennis <dkorpel@live.nl> --- (In reply to yebblies from comment #8) > eg. > pure void foo(string x) > By definition calling foo does no observable work. False. ``` pure void foo(string x) { throw new Exception(x); } ``` Here's a nothrow one: ``` pure nothrow void assertPositive(int x) { assert(x > 0); } ``` > While this might be WONTFIX or LATER like issue 3882, it is not invalid. Until a case can be identified where there is actually "no observable work" guaranteed, this is invalid. (And even then, it's debatable whether "no observable work" is enough grounds to make something not compile. `int x = 0; x += 0;` does nothing, but it does and should compile.) -- |
March 25, 2020 [Issue 3572] declaring pure function with void return type should be compile time error | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=3572 --- Comment #10 from Michal Minich <michal.minich@gmail.com> --- Agreed. even pure void nothrow never() { assert(false); } can throw Error, which is observable effect. -- |
Copyright © 1999-2021 by the D Language Foundation