www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - 'auto pure' is up, how about 'auto safe'?

reply KennyTM~ <kennytm gmail.com> writes:
'auto pure' (actually, purity inference) has been integrated in commit 
'dfb68'*, Thanks Walter:

------------------------------
int y()(int x) {  // <-- pure is inferred for template function
     return 0;
}
void main() pure {
     y(2);
}
------------------------------



But I think it should be able to detect  safe as well:

------------------------------
int y()(int x) {
     return 0;
}
void main()  safe {
     y(2);
}
------------------------------
y.d(5): Error: safe function 'main' cannot call system function 'y'
------------------------------


*: https://github.com/D-Programming-Language/dmd/commit/dfb68
Jun 20 2011
parent Walter Bright <newshound2 digitalmars.com> writes:
On 6/20/2011 2:42 AM, KennyTM~ wrote:
 But I think it should be able to detect  safe as well:

Sure, and nothrow too. But I thought I'd start with purity.
Jun 20 2011