[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 github-bugzi...@puremagic.com changed: What|Removed |Added Status|REOPENED|RESOLVED Resolution|--- |FIXED --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 --- Comment #8 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/2dbc2bd85d5e5a55a3bcbf362c60cb0648102a73 fix Issue 18282 part 2 https://github.com/dlang/dmd/commit/bbe466b97fe5d2fa9f2914937f42079a987579d2 Merge pull request #8045 from WalterBright/fix18282-2 fix Issue 18282 part 2 merged-on-behalf-of: Walter Bright--
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 --- Comment #7 from Walter Bright--- https://github.com/dlang/dmd/pull/8045 --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 ag0aep6gchanged: What|Removed |Added Status|RESOLVED|REOPENED Resolution|FIXED |--- --- Comment #6 from ag0aep6g --- (In reply to Walter Bright from comment #4) > https://github.com/dlang/dmd/pull/8030 That seems to have fixed this snippet from comment #2: string* f() @safe { scope string*[] ls; return ls[0]; } But the original test case still fails: void main() @safe { string foo = "foo"; scope string*[] ls; ls ~= /* Error. But this works: ls = ls ~ */ } Looks like the actual issue hasn't been fixed. Reopening. --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 github-bugzi...@puremagic.com changed: What|Removed |Added Status|REOPENED|RESOLVED Resolution|--- |FIXED --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 --- Comment #5 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/ac0224287fd16d293081059acef7c23b94212a7b fix Issue 18282 - [Scope][DIP1000]Assignment of local variable to variable not recognized by compiler https://github.com/dlang/dmd/commit/718350da81d5c2d1f18e0eb7b6e6ec69d1e69c34 Merge pull request #8030 from WalterBright/fix18282 fix Issue 18282 - [Scope][DIP1000]Assignment of local variable to va… merged-on-behalf-of: Mike Franklin--
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 Carsten Blüggelchanged: What|Removed |Added CC||chi...@posteo.net --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 --- Comment #4 from Walter Bright--- https://github.com/dlang/dmd/pull/8030 --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 Walter Brightchanged: What|Removed |Added Status|RESOLVED|REOPENED Resolution|INVALID |--- --- Comment #3 from Walter Bright --- I'll reopen it and look at it again. --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 ag0ae...@gmail.com changed: What|Removed |Added CC||ag0ae...@gmail.com --- Comment #2 from ag0ae...@gmail.com --- (In reply to Walter Bright from comment #1) > (In reply to Mike Franklin from comment #0) > > void main() @safe > > { > > string foo = "foo"; > > scope string*[] ls; > > ls ~= > > } > > > > 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. I assume that you don't mean `ls[]` literally, but rather that the elements of `ls` aren't `scope`, right? That means, it should be okay to return `ls[0]` because that's not `scope`, right? But that doesn't work: string* f() @safe { scope string*[] ls; return ls[0]; /* Error: scope variable ls may not be returned */ } On the other hand, this works: void main() @safe { string foo = "foo"; scope string*[] ls; ls = ls ~ } The only difference from the original code is `ls ~= ` -> `ls = ls ~ `. Those two assignments should be equivalent [1], no? Either both should be accepted, or both should be rejected. [1] https://dlang.org/spec/expression.html#assignment_operator_expressions --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 Walter Brightchanged: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution|--- |INVALID --- Comment #1 from Walter Bright --- (In reply to Mike Franklin from comment #0) > void main() @safe > { > string foo = "foo"; > scope string*[] ls; > ls ~= > } > > 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 ~= > } > > 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.) --
[Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler
https://issues.dlang.org/show_bug.cgi?id=18282 Mike Franklinchanged: What|Removed |Added Summary|Assignment of local |[Scope][DIP1000]Assignment |variable to `scope` |of local variable to |variable not recognized by |`scope` variable not |compiler|recognized by compiler --