D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9090 - auto ref doesn't work with arrays
Summary: auto ref doesn't work with arrays
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-11-27 23:18 UTC by Jack Applegame
Modified: 2012-12-09 17:03 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jack Applegame 2012-11-27 23:18:41 UTC
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 2 Martin Nowak 2012-12-07 11:34:41 UTC
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 Martin Nowak 2012-12-07 11:42:23 UTC
(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 github-bugzilla 2012-12-07 19:01:04 UTC
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