Bug 9632 – Detect Non-Mutating Call Statements to Pure Functions
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-02T04:02:00Z
Last change time
2013-03-02T05:36:15Z
Assigned to
nobody
Creator
per.nordlow
Comments
Comment #0 by per.nordlow — 2013-03-02T04:02:00Z
I believe D has the potential to add yet another cool feature to its suite of compilers, namely the power to disallow non-side-effect calls to pure functions.
For example
auto s = "a";
toStringz(a);
should error just like
a == "";
currently errors in DMD as
Error: == has no effect in expression (s == "")
Such as feature would prevent the programmer from accidentally calling non-muting algorithms when he expects it to have in-place (mutating) semantics which has cost me a lot of debugging hours. Is such a feature on the todo list for DMD?
Also see http://stackoverflow.com/questions/15173942/detect-non-mutating-call-statements-to-pure-functions-in-d
Comment #1 by bearophile_hugs — 2013-03-02T05:36:15Z
*** This issue has been marked as a duplicate of issue 3882 ***