[Issue 24003] return/scope inference does not end up in type to some degree
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 23 12:03:17 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24003
Ate Eskola <Ajieskola at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Ajieskola at gmail.com
--- Comment #3 from Ate Eskola <Ajieskola at gmail.com> ---
I think this is same as what I was just about to report:
```d
auto nullPtr(int*) => (int*).init;
@safe unittest
{ int local;
// compiles (with -preview=dip1000), because the parameter is correctly
inferred as scope
auto nullP = nullPtr(&local);
}
// Yet this says AliasSeq!().
// Should say AliasSeq!"scope".
pragma(msg, __traits(getParameterStorageClasses, nullPtr, 0));
```
I was solving https://issues.dlang.org/show_bug.cgi?id=23300, but this bug is
blocking me. Since `scope` inference is limited, `std.array.array` needs to
manually introspect whether `.front` / `.opApply` / element copy of the source
range are `scope`. With this bug, it only works in the rare few cases where
`scope` is manually specified.
I have tried working around it by testing whether a call passing a `scope`
argument compiles, but no joy. DIP1000 checks are only done in safe code, and
trying to cast a `@system` function to a `@trusted` one to make the check work,
without changing the function type in any other way or losing the `scope`
inference, was just too difficult for me - probably impossible.
--
More information about the Digitalmars-d-bugs
mailing list