[phobos] I applied @safe, @trusted, @system to Phobos!

Shin Fujishiro rsinfu at gmail.com
Sat May 22 20:46:57 PDT 2010


SHOO <zan77137 at nifty.com> wrote:
> I succeeded in applying @safe, @trusted, @system to Phobos after hardship.
> 
> I made a branch, please look:
> http://svn.dsource.org/projects/phobos/branches/devel/applying_safe_system_trusted
> 

Great work!

> 7. Some mysterious compile errors
>     When @safe unittest...
>     Some functions are going to call opAssign. (eg: std.range(2670))
>     Some functions are going to call __cpctor. (eg: std.stdio(165))
>     Some functions are going to call ~this. (eg: std.stdio(872))
>     (I try compile command: "dmd -I.. -c -o- -unittest -debug stdio.d")

It seems module-global @safe is not applied into struct/class scopes.
I'm not sure if this is a bug though.

This example doesn't compile:
--------------------
@safe:
struct S {
    void foo() { }
    @safe unittest { foo(); }
}
--------------------
% dmd -o- -c -unittest test
test.d(4): Error: safe function '__unittest1' cannot call...
--------------------

While this one compiles:
--------------------
@safe:
struct S {
@safe: // <-- !!
    void foo() { }
    unittest { foo(); }
}
--------------------

Hope this can be helpful for you. :)

Shin


More information about the phobos mailing list