/*
-REQUIRED_ARGS: -dip1000
-PERMUTE_ARGS:
+REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
-fail_compilation/retscope.d(23): Error: scope variable `p` may not be returned
-fail_compilation/retscope.d(33): Error: returning `b ? nested1(& i) : nested2(& j)` escapes a reference to local variable `j`
-fail_compilation/retscope.d(46): Error: scope variable `p` assigned to non-scope `q`
-fail_compilation/retscope.d(48): Error: address of variable `i` assigned to `q` with longer lifetime
-fail_compilation/retscope.d(49): Error: variadic variable `a` assigned to non-scope `b`
-fail_compilation/retscope.d(50): Error: reference to stack allocated value returned by `(*fp2)()` assigned to non-scope `q`
+fail_compilation/retscope.d(22): Error: scope variable `p` may not be returned
+fail_compilation/retscope.d(32): Error: returning `b ? nested1(& i) : nested2(& j)` escapes a reference to local variable `j`
+fail_compilation/retscope.d(45): Error: scope variable `p` assigned to non-scope `q`
+fail_compilation/retscope.d(47): Error: address of variable `i` assigned to `q` with longer lifetime
+fail_compilation/retscope.d(48): Error: scope variable `a` assigned to non-scope `b`
+fail_compilation/retscope.d(49): Error: address of struct temporary returned by `(*fp2)()` assigned to longer lived variable `q`
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(76): Error: function retscope.HTTP.Impl.onReceive is @nogc yet allocates closures with the GC
-fail_compilation/retscope.d(78): retscope.HTTP.Impl.onReceive.__lambda1 closes over variable this at fail_compilation/retscope.d(76)
+fail_compilation/retscope.d(75): Error: function `retscope.HTTP.Impl.onReceive` is `@nogc` yet allocates closures with the GC
+fail_compilation/retscope.d(77): retscope.HTTP.Impl.onReceive.__lambda1 closes over variable this at fail_compilation/retscope.d(75)
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(97): Error: reference to local variable `sa` assigned to non-scope parameter `a` calling retscope.bar8
+fail_compilation/retscope.d(96): Error: reference to local variable `sa` assigned to non-scope parameter `a` calling retscope.bar8
---
*/
// https://issues.dlang.org/show_bug.cgi?id=8838
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(124): Error: returning `foo9(cast(char[])tmp)` escapes a reference to local variable `tmp`
+fail_compilation/retscope.d(123): Error: returning `foo9(cast(char[])tmp)` escapes a reference to local variable `tmp`
---
*/
/*
//
//
-//fail_compilation/retscope.d(143): To enforce @safe compiler allocates a closure unless the opApply() uses 'scope'
+//fail_compilation/retscope.d(143): To enforce `@safe`, the compiler allocates a closure unless `opApply()` uses `scope`
//
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(159): Error: scope variable `this` may not be returned
+fail_compilation/retscope.d(158): Error: scope variable `this` may not be returned
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(178): Error: address of variable `i` assigned to `p` with longer lifetime
+fail_compilation/retscope.d(177): Error: address of variable `i` assigned to `p` with longer lifetime
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(198): Error: scope variable `e` may not be returned
+fail_compilation/retscope.d(197): Error: scope variable `e` may not be returned
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(213): Error: scope variable `p` assigned to non-scope `e`
+fail_compilation/retscope.d(212): Error: scope variable `p` assigned to non-scope `e.e`
---
*/
struct Escaper3 { void* e; }
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(230): Error: scope variable `ptr` may not be returned
+fail_compilation/retscope.d(229): Error: scope variable `ptr` may not be returned
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda1` of type `void* delegate() pure nothrow @nogc return @safe` to `void* delegate() @safe`
-fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda1` of type `void* delegate() pure nothrow @nogc return @safe` to `void* delegate() @safe`
-fail_compilation/retscope.d(250): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc return @safe` to `void* delegate() @safe`
-fail_compilation/retscope.d(250): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc return @safe` to `void* delegate() @safe`
+fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
+fail_compilation/retscope.d(248): Error: cannot implicitly convert expression `__lambda2` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
+fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
+fail_compilation/retscope.d(249): Error: cannot implicitly convert expression `__lambda4` of type `void* delegate() pure nothrow @nogc @safe` to `void* delegate() @safe`
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(267): Error: cannot take address of scope local p in @safe function escape5
+fail_compilation/retscope.d(266): Error: cannot take address of `scope` local `p` in `@safe` function `escape5`
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(287): Error: returning `foo6(& b)` escapes a reference to local variable `b`
+fail_compilation/retscope.d(286): Error: returning `foo6(& b)` escapes a reference to local variable `b`
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(320): Error: reference to local variable `i` assigned to non-scope `f`
+fail_compilation/retscope.d(319): Error: reference to local variable `i` assigned to non-scope `f`
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(343): Error: cannot take address of scope local aa in @safe function escape11
+fail_compilation/retscope.d(342): Error: cannot take address of `scope` local `aa` in `@safe` function `escape11`
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(1405): Error: reference to local variable `buf` assigned to non-scope parameter `unnamed` calling retscope.myprintf
+fail_compilation/retscope.d(1405): Error: reference to local variable `buf` assigned to non-scope parameter `__anonymous_param` calling retscope.myprintf
---
*/
/*
TEST_OUTPUT:
---
-fail_compilation/retscope.d(1509): Error: reference to stack allocated value returned by `(*fp15)()` assigned to non-scope parameter `unnamed`
+fail_compilation/retscope.d(1509): Error: reference to stack allocated value returned by `(*fp15)()` assigned to non-scope parameter `__anonymous_param`
---
*/
TEST_OUTPUT:
---
fail_compilation/retscope.d(1701): Error: cannot implicitly convert expression `& func` of type `int* function(int* p)` to `int* function(scope int* p)`
-fail_compilation/retscope.d(1702): Error: cannot implicitly convert expression `& func` of type `int* function(int* p)` to `int* function(return scope int* p)`
+fail_compilation/retscope.d(1702): Error: cannot implicitly convert expression `& func` of type `int* function(int* p)` to `int* function(return int* p)`
fail_compilation/retscope.d(1703): Error: cannot implicitly convert expression `& func` of type `int* function(int* p)` to `int* function(return scope int* p)`
-fail_compilation/retscope.d(1711): Error: cannot implicitly convert expression `& funcr` of type `int* function(return scope int* p)` to `int* function(scope int* p)`
+fail_compilation/retscope.d(1711): Error: cannot implicitly convert expression `& funcr` of type `int* function(return int* p)` to `int* function(scope int* p)`
fail_compilation/retscope.d(1716): Error: cannot implicitly convert expression `& funcrs` of type `int* function(return scope int* p)` to `int* function(scope int* p)`
---
*/
foo22(s);
}
+/*********************************************
+TEST_OUTPUT:
+---
+fail_compilation/retscope.d(1907): Error: scope variable `x` assigned to `this` with longer lifetime
+fail_compilation/retscope.d(1913): Error: scope variable `x` may not be returned
+---
+*/
+#line 1900
+struct Constant
+{
+ int* member;
+
+ int* foo(scope Repeat!(int*) grid) @safe
+ {
+ foreach(ref x; grid)
+ member = x;
+
+ foreach(ref x; grid)
+ x = member;
+
+ foreach(ref x; grid)
+ return x;
+
+ return null;
+ }
+
+ alias Repeat(T...) = T;
+}