www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20820] New: [ob][DIP1021]Borrowing by a scope variable is not

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

          Issue ID: 20820
           Summary: [ob][DIP1021]Borrowing by a scope variable is not
                    equivalent to a scope argument
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: lempiji gmail.com

Would it be appropriate for the following two to behave differently?
I think both should be NG for the same reasons.

https://run.dlang.io/is/X7Xf8l

```
import std;
import core.stdc.stdlib;

void main()  live {
    auto p = cast(byte*) malloc(10);
    scope(exit) free(p);

    scope ps = p[0 .. 10];
    writeln(ps); // NG
    //writelns(ps); // OK
}

void writelns(Args)(scope Args args...)
{
    writeln(args);
}
```

--
May 11