Bug 18000 – [scope] auto-generated opAssign not scope aware

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-11-21T15:20:55Z
Last change time
2018-03-13T06:05:20Z
Keywords
safe
Assigned to
No Owner
Creator
Martin Nowak
See also
https://issues.dlang.org/show_bug.cgi?id=18592

Comments

Comment #0 by code — 2017-11-21T15:20:55Z
cat > bug.d << CODE module bug; struct File { @safe @nogc: ~this() scope { } void* f; } void test() @safe @nogc { scope File f; f = File(); } CODE dmd -c -dip1000 bug ---- bug.d(16): Error: scope variable f assigned to non-scope parameter this calling bug.File.opAssign ---- We should infer scope for any auto-generated functions like opAssign.
Comment #1 by bugzilla — 2018-03-12T02:41:31Z
Attributes are inferred for the generated opAssign, the result looks like: @nogc ref return @trusted File opAssign(File p) Not sure why scope is not inferred. In any case, the example has problems as well: scope File f; f = File(); The lifetime of File() is less than that of f, so this example should fail to compile for that reason. https://issues.dlang.org/show_bug.cgi?id=17977 addresses that.
Comment #2 by bugzilla — 2018-03-12T08:16:38Z
Comment #3 by github-bugzilla — 2018-03-12T16:04:17Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/ddef69767da510fce048fc13f8b66e79765cccb5 fix Issue 18000 - [scope] auto-generated opAssign not scope aware https://github.com/dlang/dmd/commit/133973354df526664b22cacdf488785fa911209f Merge pull request #8011 from WalterBright/fix18000 fix Issue 18000 - [scope] auto-generated opAssign not scope aware merged-on-behalf-of: Walter Bright <[email protected]>