August 29, 2022
https://issues.dlang.org/show_bug.cgi?id=22916

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #11 from Dennis <dkorpel@live.nl> ---
(In reply to Walter Bright from comment #9)
> That difference makes all the difference.

No it does not. Whether I have a `scope int[]` or `scope string[]`, the scope only applies to the first indirection of the array, not the array elements. If I index a `scope string[]` and get a `scope string`, it's a bug.

> The trouble is the code is trying to store a scope protected value `int* p` into the unprotected payload pointer `*ptr`. There's no way dip1000 can do that.

Of course not, but the issue is that it shouldn't be a scope protected value in the first place because it came from a dereferenced pointer, after which `scope` shouldn't apply anymore. This is deduced from the function signature using `return scope` by the way, NOT from the return expression.

Please stop closing this issue based on false premises.

I'm not incorrectly annotating the function `return scope`.
I'm not trying to cheat transitive scope.
I'm not asking to inspect the return expression to gain more information than
the function signature provides.
I'm not saying a scope pointer may be assigned to a non-scope parameter.

> You'll have to use @trusted code.

The whole point of dip1000 is that stack-allocated arrays become usable in @safe code. If we can't allow indexing or assigning array elements without @trusted, it defeats the purpose.

--
October 10, 2022
https://issues.dlang.org/show_bug.cgi?id=22916

--- Comment #12 from Dennis <dkorpel@live.nl> ---
I've found a workaround for this issue by the way: convert the `ref` return to
a pointer and dereference that to get the non-scope value.
```
// compile with -preview=dip1000
@safe:
struct Arr
{
    int** ptr;

    ref int* index() return scope {
        return *ptr;
    }

    void assign(int* p) scope {
        *ptr = p;
    }
}

void main()
{
    scope Arr a;

    a.assign(*&a.index());

    auto tmp = &a.index();
    a.assign(*tmp);
}
```

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22916

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
February 09, 2023
https://issues.dlang.org/show_bug.cgi?id=22916

--- Comment #13 from Dennis <dkorpel@live.nl> ---
*** Issue 23682 has been marked as a duplicate of this issue. ***

--
February 10, 2023
https://issues.dlang.org/show_bug.cgi?id=22916

Walter Bright <bugzilla@digitalmars.com> changed:

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

--
February 11, 2023
https://issues.dlang.org/show_bug.cgi?id=22916

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #14 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #14871 "Fix 22916 - copy of ref return still treated as scope variable" fixing this issue:

- Fix 22916 - copy of ref return still treated as scope variable

https://github.com/dlang/dmd/pull/14871

--
February 20, 2023
https://issues.dlang.org/show_bug.cgi?id=22916

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #15 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14871 "Fix 22916 - copy of ref return still treated as scope variable" was merged into master:

- 21375505508e2cc03395988de9702305c030378f by Dennis Korpel:
  Fix 22916 - copy of ref return still treated as scope variable

https://github.com/dlang/dmd/pull/14871

--
1 2
Next ›   Last »