ВК
Size: a a a
ВК
ВК
OB
ВК
ВК
DH
EP
O
// dip1000, return scope, @safe - 3 в одном, иначе не проверяет
// {ldc2 | dmd} -dip1000 live.d
import std, std.algorithm;
struct Buf {
byte[20] buf;
string getStr() return scope @trusted {
auto posz = buf[].countUntil( 0);
return cast( string )buf[ 0..posz];
}
}
struct S { string s; }
string glob;
string func( byte[20] bytes) @safe { // should be safe for scope checking
auto buf = Buf( bytes);
"|%s|".writefln( buf.buf);
auto local = buf.getStr();
"|%s|".writefln( local);
//glob = local; // ERROR for -dip1000
//return local; // ERROR for -dip1000
//return S( local); // ERROR for -dip1000 when "S func(..)"
return "ok";
}
void main() {
auto res = func( cast( byte[20] )"Hello world!");
"|%s|".writefln( res);
"|%s|".writefln( glob);
}
И
O
КП