[Issue 22041] SumType assignments should work with pointers in @safe code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 18 19:05:29 UTC 2021


Dlang Bot <dlang-bot at dlang.rocks> changed:

           What    |Removed                     |Added
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot at dlang.rocks> ---
@ljmf00 created dlang/phobos pull request #8146 "sumtype: remove forced @system
for opAssign preventing @safe code" fixing this issue:

- sumtype: remove forced @system for opAssign preventing @safe code

  Fixes #22041 .

  D programming language is moving towards @safe code and introducing new
  @system code makes std.sumtype fundamentally useless when using it under
  code. Forcing @system when the users are using pointers is just wrong.

  The simple example to prove it is the following:

  void main() @safe
      int* thisIsNotUnsafe = new int;

  Using pointers in D is not necessarily @system.

  Moreover, this code is preventing the following code to compile in @safe:

  alias FooBar = SumType!string;
  auto foobar = FooBar("foo");
  foobar = FooBar("bar");

  Signed-off-by: Luís Ferreira <contact at lsferreira.net>



More information about the Digitalmars-d-bugs mailing list