[Issue 3882] Unused result of pure functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 1 16:59:28 PST 2014


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



--- Comment #20 from bearophile_hugs at eml.cc 2014-03-01 16:59:27 PST ---
(In reply to comment #19)

> What does test.f!int.f mean?
> ...
> @safe pure nothrow T f(T)(T x)
> {
>     return x*x;
> }
> void main(string args[])
> {
>     int x = 3;
>     f(x);
> }

f here is not a function, it's a function template.

This code:

@safe pure nothrow T f(T)(T x) {
    return x*x;
}

Is the same as:

template f(T) {
    @safe pure nothrow T f(T x) {
        return x*x;
    }
}

So when you call f inside the test module with an int you are actually calling
test.f!int.f

For a templated function the second f is redundant in the error message.

-- 
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