What does it mean for a pure function to return pure?
pure int doubleMe(in int i) pure { return i * 2; }
The code compiles without giving redundant storage class pure
, so I suppose this is not a bug?
// DMD 2.056
What does it mean for a pure function to return pure?
pure int doubleMe(in int i) pure { return i * 2; }
The code compiles without giving redundant storage class pure
, so I suppose this is not a bug?
// DMD 2.056
Pure is a function attribute. Function attributes can go before the return type or after the parameter list. It describes the function, not the return type, in both cases. Hence, there is no such thing as "returning pure".
It should raise an error, it's probably a bug. The same thing is ignored with some other attributes too, like @safe.
pure int
probably should be ignored. However, I believe the reason why we have it is that a function may return a "pure function". In that case I think it is arguable whether it is a bug or not.