Bug 9517 – Safety/purity/etc. of mixin code should not depend on generating function
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-14T20:53:00Z
Last change time
2013-02-16T17:47:19Z
Assigned to
nobody
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2013-02-14T20:53:44Z
import std.stdio;
string makeCode() @system
{
return "return true;";
}
bool func() @safe // <--- does not compile
{
mixin(makeCode());
}
void main()
{
writeln(func());
}
Apparently, DMD regards func() as calling makeCode(), but actually this is done at compile-time, not runtime, so func() should be @safe. Similarly with pure, nothrow, etc..
The attributes of func() should derive from the *return value* of makeCode(), not makeCode() itself.
Comment #1 by yebblies — 2013-02-16T17:47:19Z
*** This issue has been marked as a duplicate of issue 6169 ***