October 20, 2016
https://issues.dlang.org/show_bug.cgi?id=12625

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe

--
March 16, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

--- Comment #17 from ZombineDev <petar.p.kirov@gmail.com> ---
*** Issue 17261 has been marked as a duplicate of this issue. ***

--
March 16, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

--- Comment #18 from hsteoh@quickfur.ath.cx ---
Marking this as accepts-invalid, because this code is allowed even with -dip1000:

------
int[16] func();
int[] a = func();
------

According to DIP 1000:

1) Lifetimes of statically-sized arrays T[n] is analyzed as if the array were a struct with n fields, each of type T. [Under "Aggregates"]

2) For types without indirections such as int, reachability and lifetime are equal for rvalues and lvalues. [Under "Definitions" > "Reachability vs. lifetime"]

3) For an rvalue, the reachability is the expression within which it is used. [Under "Definitions" > "Reachability vs. lifetime"]

4) The lifetime of e[] (implicit in this case) is lifetime(e) [Under
"Definitions" > "Algebra of lifetimes"]

5) A scope variable can only be initialized and assigned from values that have lifetimes longer than the variable's lifetime. [Under "Fundamentals of scope"]

Point (1) indicates that static arrays should be analysed as structs with n fields, and therefore int[n] is subject to (2): reachability and lifetime are equal. Point (3) indicates that an rvalue has reachability equal to the expression in which it is used, which, by point (2), implies that the lifetime of the static array is also the expression in which it is used. Then the slice produced by the implicit slicing, according to (4), must also have the same lifetime, i.e., the expression in which the rvalue occurs.

Since the lifetime of `a` in the code above is longer than the lifetime of the expression on the right-hand side, by (5) this assignment is illegal.

So, the fact that -dip1000 lets this code through is a bug in the implementation of DIP 1000.

--
August 07, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com
            Summary|implicit slicing of RValue  |[DIP1000] implicit slicing
                   |static array should be      |of RValue static array
                   |illegal                     |should be illegal

--
August 07, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[DIP1000] implicit slicing  |[scope] [DIP1000] implicit
                   |of RValue static array      |slicing of RValue static
                   |should be illegal           |array should be illegal

--
August 31, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

Walter Bright <bugzilla@digitalmars.com> changed:

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

--- Comment #19 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/7110

--
August 31, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

--- Comment #20 from Steven Schveighoffer <schveiguy@yahoo.com> ---
For those not following the PR in Phobos discussion, an interesting alternative idea has been floated by ZombineDev:

char[16] get();

string s = get();

// can be lowered to:
auto _tmp = get();
scope string s = _tmp[];

Which should work and keep existing code intact. Requires dip1000 I believe.

--
November 10, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=17977

--
November 29, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

--- Comment #21 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/f0372315ca3d3dc87e67768433d446832348fe47 Issue 12625 - [scope] [DIP1000] implicit slicing of RValue static array should be illegal

https://github.com/dlang/phobos/commit/a3bbaedcef197c6db91bea4f4ccf7f85c03c8d8c Merge pull request #5893 from JinShil/fix_12625

Issue 12625 - [scope] [DIP1000] implicit slicing of RValue static array should
be illegal
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>

--
November 30, 2017
https://issues.dlang.org/show_bug.cgi?id=12625

--- Comment #22 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/b8cb63a01cc20051f0f057a1556bcec1533443fa fix Issue 12625 - [scope] [DIP1000] implicit slicing of RValue static array should be illegal

https://github.com/dlang/dmd/commit/b1209169eeac242f879cc7c9a3a0f928c1be3c02 Merge pull request #7110 from WalterBright/fix12625

fix Issue 12625 - [scope] [DIP1000] implicit slicing of RValue static… merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>

--