[Issue 23124] [dip1000] scope and return should not be inferred for @trusted function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 26 17:44:03 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23124
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla at digitalmars.com
Resolution|--- |INVALID
--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> ---
The error is:
test.d(17): Error: scope variable `myVar` assigned to `outer` with longer
lifetime
which is a correct error message. `outer` lives longer than the scope of
`inner`, so it is an error to set `outer` to pointing at `inner`.
If you need it to compile, remove `@safe` from main().
It's a feature of D to do scope inference. Whether the use of a scope pointer
is checked or not is dependent on whether the function using the scope pointer
is @safe or not.
This is working as designed.
--
More information about the Digitalmars-d-bugs
mailing list