[Issue 3882] Unused result of pure functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 1 15:28:14 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=3882



--- Comment #13 from Per Nordlöw <per.nordlow at gmail.com> 2014-03-01 15:28:11 PST ---
(In reply to comment #12)
> (In reply to comment #11)
> 
> > This pull request adds warnings for unused non-void returns of calls to
> > strictly pure function calls.
> 
> Is adding a cast(void) before the function call able to disable this warning?

Yes, adding cast(void) in front of expression disables warning.

> If this is false then perhaps it's worth adding this sub-feature and then I
> suggest a shorter and more useful warning message like:
> 
> Warning: Function call to pure function foo() discards return value, prepend a
> cast(void) if intentional.

This is a very good idea. I'll implement this.

It still think it would be useful to also show the context of the called
function. What do you think?

> > For this to work Phobos had to altered in handful
> > of places were non-void returns were not captured.
> 
> Some user code will need similar changes...

I believe its worth the stretch because it can help us capture potential bugs.
It caught two for me.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list