[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 12 03:32:22 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18282
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> ---
(In reply to Mike Franklin from comment #0)
> void main() @safe
> {
> string foo = "foo";
> scope string*[] ls;
> ls ~= &foo;
> }
>
> Compile with `-dip1000`
>
> onlineapp.d(5): Error: reference to local variable foo assigned to non-scope
> ls
While ls is scope, ls[] is not scope. Scope is not transitive, hence the
compiler error.
> The compiler doesn't seem to recognize that ls is attributed with `scope`.
> However due to the way D's attributes are parsed, I'm not sure if it should
> actually be `scope string*[]`, `scope(string*)[]`, or `scope(string*[])`.
> Anyway, if you use `scope()` (i.e. with parens) the compiler confuses it
> with `scope(exit)` and friends.
>
>
> void main() @safe
> {
> string foo = "foo";
> scope(string*[]) ls;
> ls ~= &foo;
> }
>
> Compile with `-dip1000`
>
> onlineapp.d(4): Error: valid scope identifiers are exit, failure, or
> success, not string
Scope is a storage class, not a type constructor. (`const`, for example, is a
type constructor, and `static` is a storage class.)
--
More information about the Digitalmars-d-bugs
mailing list