Bug 14788 – Incorrect rejection of inout function call

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-08T13:14:00Z
Last change time
2016-03-19T20:21:48Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2015-07-08T13:14:00Z
Following code does not compile, but it should. auto make(K, V)(inout V[K] aa) { static struct Result { V[K] aa; ref front() inout { return aa[1]; } } return inout Result(aa); } void main() { int[int] aa = [1:1]; make(aa).front(); // line 14 } Output: $ dmd -o- test test.d(14): Error: modify inout to mutable is not allowed inside inout function ---- If the 'Result' struct is not static, the error is not wrong. Because the returned reference by Result.front() may come from the local state of enclosing 'make' function. However the 'Result' is actually static and it cannot access outer inout function context. Therefore the compile error is not correct. This compiler bug is blocking fix for the regression issue 14626.
Comment #1 by k.hara.pg — 2015-07-16T14:25:58Z
(In reply to Kenji Hara from comment #0) > This compiler bug is blocking fix for the regression issue 14626. Now it's not required.
Comment #2 by k.hara.pg — 2015-07-16T14:26:09Z
Comment #3 by github-bugzilla — 2016-02-07T04:16:56Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/565ff8d8c6496208dd51c751a9b1d947b70dd36c fix Issue 14788 - Incorrect rejection of inout function call https://github.com/D-Programming-Language/dmd/commit/0a15e859e6ffb5e7180bf49169f61da998d4466a Merge pull request #4810 from 9rnsr/fix14788 Issue 14788 - Incorrect rejection of inout function call
Comment #4 by github-bugzilla — 2016-03-19T20:21:48Z