Bug 19035 – Escape in scope inference, improve scope inference

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-28T04:47:35Z
Last change time
2018-07-01T21:02:36Z
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2018-06-28T04:47:35Z
Consider: ---------- @safe: void escape(int*); /**********************/ void frank()(ref scope int* p, int* s) { p = s; // should error here, does not } void testfrankly() { int* p; int i; frank(p, &i); // note that p now has a reference to i, and can outlast i } /**********************/ void betty()(int* p, int* q) { p = q; escape(p); } void testbetty() { int i; int j; betty(&i, &j); // should error on i and j, and it does } /**********************/ void archie()(int* p, int* q, int* r) { p = q; r = p; escape(q); } @safe void testarchie() { int i; int j; int k; archie(&i, &j, &k); // should error only on j, not i and j } -------
Comment #1 by bugzilla — 2018-06-28T04:54:18Z
Comment #2 by github-bugzilla — 2018-07-01T21:02:34Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/9475d8685f06a3d6872fc459800a25cc002adfe5 fix Issue 19035 - Escape in scope inference, improve scope inference https://github.com/dlang/dmd/commit/d917058d78596902045e34c707c5bf644555fb0e Merge pull request #8408 from WalterBright/maybescope fix Issue 19035 - Escape in scope inference, improve scope inference