serve-d
serve-d copied to clipboard
Code action to add @safe/trusted/system
The errors
file.d(n): Error: @safe function <func> cannot call @system function <func>
and
file.d(n): Error: <anything> not allowed in safe code
should have code actions to fix.
Example:
void safeFunc()
{
<unsafe erroring stuff>
}
should suggest, when on the error:
- Mark function as
@system
- Mark call as
@trusted
Mark function as @system
should do the obvious:
void safeFunc() @system
{
<unsafe erroring stuff>
}
Mark call as @trusted
should do one the following:
unsafe erroring stuff is a single statement:
void safeFunc() @system
{
(() @trusted => <unsafe erroring stuff>)();
}
unsafe erroring stuff is a block of statements: (wouldn't actually be used for now because it only acts by error messages which is gonna be at most a statement)
void safeFunc() @system
{
(() @trusted {
<unsafe erroring stuff>
})();
}