Bug 9090 – auto ref doesn't work with arrays

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-27T23:18:00Z
Last change time
2012-12-09T17:03:16Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
japplegame

Comments

Comment #0 by japplegame — 2012-11-27T23:18:41Z
void test1(T)(auto ref const T[] val) {} void main() { string a; test1(a); } Output: Error: cast(const(char[]))a is not an lvalue
Comment #1 by k.hara.pg — 2012-12-07T06:37:22Z
Comment #2 by code — 2012-12-07T11:34:41Z
This also happens with ref and plain types. ---- void test1(ref const char[] val) {} void main() { string a; test1(a); } ---- void test1(ref const(char) val) {} void main() { immutable char a; test1(a); } ----
Comment #3 by code — 2012-12-07T11:42:23Z
(In reply to comment #2) > This also happens with ref and plain types. > Does an implicit const cast means to become an rvalue. But still auto ref and implicit const cast doesn't work for integral types too. void test1()(auto ref const char val) {} void main() { immutable char a; test1(a); }
Comment #4 by github-bugzilla — 2012-12-07T19:01:04Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/03e88e1a731dd941dad4861134e8568abe54ab1b fix Issue 9090 - auto ref doesn't work with arrays https://github.com/D-Programming-Language/dmd/commit/3302a4b852772d24c0735419a35cba0b754100aa Merge pull request #1354 from 9rnsr/fix9090 Issue 9090 - auto ref doesn't work with arrays