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

SHOO zan77137 at nifty.com
Sat May 22 04:36:50 PDT 2010

I succeeded in applying @safe, @trusted, @system to Phobos after hardship.

I made a branch, please look:


I discovered some bugs and problems about @safe, @trusted, @system
during my work.

1. Bugzilla 4211 - struct with annotation(@safe)
    See also http://d.puremagic.com/issues/show_bug.cgi?id=4211

2. Bugzilla 4218 - safe function cannot call opApply
    See also http://d.puremagic.com/issues/show_bug.cgi?id=4218

3. I cannot apply @safe to intrinsic operation(eg: std.math.sqrt)
    This causes mangling that had been influenced by @safe/@trusted.
    dmd converts a specific symbol into intrinsic operation. However,
dmd cannot convert symbols that are marked by @safe/@trusted.
    I am skeptical about the influence on mangling rule by @safe.

4. dmd should not allow overload between @safe/@trusted and @system
    Document says "Functions are overloaded based on how well the
arguments to a function can match up with the parameters."
    But @safe functions can overload between @system functions, though
@safe is unrelated to parameters.
    It's enough to have only @safe function.

5. druntime's modules are not applying @safe/@system/@trusted
    This shows that Exception, TypeInfo, Thread and others are not
usable by the @safe function virtually.

6. You must make the template function @trusted by all means
    When you use template, type that is maked @system may be handed to
    Therefore @trusted is required.
    This means that every template functions cannot take benefits from

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")

Please do not make it an useless treasure.
I really wait for the day when this is used effectively.

More information about the phobos mailing list