Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 23, 2018 [Issue 18282] Assignment of local variable to `scope` variable not recognized by compiler | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18282 Mike Franklin <slavo5150@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |safe -- |
January 23, 2018 [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 Franklin <slavo5150@yahoo.com> changed: 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 -- |
March 12, 2018 [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 Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution|--- |INVALID --- Comment #1 from Walter Bright <bugzilla@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.) -- |
March 12, 2018 [Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18282 ag0aep6g@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ag0aep6g@gmail.com --- Comment #2 from ag0aep6g@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 ~= &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. 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 ~ &foo; } ---- The only difference from the original code is `ls ~= &foo;` -> `ls = ls ~ &foo;`. 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 -- |
March 13, 2018 [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 Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |--- --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> --- I'll reopen it and look at it again. -- |
March 13, 2018 [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 <bugzilla@digitalmars.com> --- https://github.com/dlang/dmd/pull/8030 -- |
March 15, 2018 [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üggel <chilli@posteo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chilli@posteo.net -- |
March 16, 2018 [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-bugzilla@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 <JinShil@users.noreply.github.com> -- |
March 16, 2018 [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-bugzilla@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |FIXED -- |
March 16, 2018 [Issue 18282] [Scope][DIP1000]Assignment of local variable to `scope` variable not recognized by compiler | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18282 ag0aep6g <ag0aep6g@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |--- --- Comment #6 from ag0aep6g <ag0aep6g@gmail.com> --- (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 ~= &foo; /* Error. But this works: ls = ls ~ &foo; */ } ---- Looks like the actual issue hasn't been fixed. Reopening. -- |
Copyright © 1999-2021 by the D Language Foundation