@safety of Array

Brad Roberts via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 12 17:41:58 PDT 2014


I've been spot checking parts of phobos today to see what all isn't 
@safe ready.  I'm not shocked that Array isn't, but doesn't it need to be?

For instance, not even the most basic of uses works:

$ git diff -U5
diff --git a/std/container/array.d b/std/container/array.d
index 4a1bfb4..2672bc6 100644
--- a/std/container/array.d
+++ b/std/container/array.d
@@ -826,11 +826,11 @@ $(D r)
          length = offset1 + tailLength;
          return this[length - tailLength .. length];
      }
  }

-unittest
+ at safe unittest
  {
      Array!int a;
      assert(a.empty);
  }

==> std/container/array.d(833): Error: safe function 
'std.container.array.__unittestL831_1' cannot call system function 
'std.container.array.Array!int.Array.~this'

I know it's a tricky implementation, but let's focus on the goal.. 
should Array be usable in @safe code?


More information about the Digitalmars-d mailing list