On Borrow Checking

Manu turkeyman at gmail.com
Mon May 12 10:55:26 UTC 2025


On Mon, 12 May 2025 at 19:41, Richard (Rikki) Andrew Cattermole via
Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> On 12/05/2025 9:24 PM, Manu wrote:
> > On Mon, 12 May 2025 at 03:55, Walter Bright via Digitalmars-d
> > <digitalmars-d at puremagic.com <mailto:digitalmars-d at puremagic.com>>
> wrote:
> >
> >     On 5/10/2025 9:07 PM, Manu wrote:
> >      > I tested that and it didn't work for me. Maybe my test was faulty
> >     somehow since
> >      > I was working through numerous combinations, I'll try it again...
> >
> >
> >     I just tried it again, with the same result.
> >
> >
> > __gshared int* g;
> > void test(scope int* x)
> > {
> >      g = x;
> > }
> >
> > I just compiled this with -dip1000, and it compiles... This looks like
> > an escape to me! What have I misunderstood here?
>
> Both ``__gshared`` and ``shared`` is disallowed by ``@safe`` (direct
> assign/access), and ``@safe`` has to be in use.
>
> ``-preview=dip1000``
>
> ```d
> int* g;
> void test(scope int* x) @safe {
>      g = x; // Error: scope variable `x` assigned to global variable `g`
> }
> ```
>
>
`scope` shouldn't depend on @safe, and Walter above said it depended only
on -dip1000.
So, if it only works with @safe, I repeat again; WHY? It's not only
redundant annotation, but it's also a ticking bomb waiting to explode... I
already commented on this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20250512/5b102172/attachment.htm>


More information about the Digitalmars-d mailing list