[Issue 17763] [scope][DIP1000] The compiler treats implicit and explicit static array slicing differently

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Aug 26 17:08:32 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17763

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to ZombineDev from comment #1)
> While previous case was rejects-valid, here's a similar one where the
> compile accepts invalid code:

Reducing the case to:

  struct Context { char[] str; }

  void main() {
    Context[1] c;
    use(c);
  }

  Context[] global;

  void use(scope ref Context[1] c) @safe {
    global = c[];
    global = c;
  }

and compiling with no flags:

  test1.d(13): Error: address of variable c assigned to global with longer
lifetime
  test1.d(14): Error: address of variable c assigned to global with longer
lifetime

compiling with -dip1000:

  test1.d(13): Error: cannot take address of scope parameter c in @safe
function use
  test1.d(14): Error: address of variable c assigned to global with longer
lifetime

The different messages are because of the different order things happen due to
the rewriting. But the error messages are still there and are correct.

Perhaps you're testing with an older compiler?

--


More information about the Digitalmars-d-bugs mailing list