Bug 6208 – Parameter storage classes are ignored in template function deducing.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-06-24T09:00:00Z
Last change time
2012-02-11T10:15:57Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2011-06-24T09:00:09Z
In the following code, ref storage class of function foo's parameter s is ignored. So calling foo with lvalue makes confusing. ---- int foo(S)(ref S s){ return 1; } int foo(S)(S s){ return 2; } void main() { int n; assert(foo(n) == 1); // Line 6 assert(foo(0) == 2); } ---- test.d(6): Error: template test.foo(S) foo(S) matches more than one template declaration, test.d(1):foo(S) and test.d(2):foo(S) ----
Comment #1 by k.hara.pg — 2011-06-24T09:01:35Z
P.S. Same problem exists with out and lazy.
Comment #2 by k.hara.pg — 2011-09-08T00:52:07Z
I found related issue. Type storage classes (in, const, immutable, shared, inout) are also ignored. void foo(T)(const T value) if (!is(T == int)) {} void main() { int n; const int cn; static assert(!__traits(compiles, foo(n))); // OK static assert(!__traits(compiles, foo(cn))); // NG }
Comment #3 by k.hara.pg — 2011-10-02T14:52:49Z
Comment #4 by bugzilla — 2011-12-15T11:23:33Z
Comment #5 by github-bugzilla — 2012-02-11T10:15:57Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6aa5805f571be5a2d393f83cbe5dd9354c366067 fix Issue 6208 with tuple parameter deduction in IFTI. If a function parameter using tuple template parameter has some storage classes, the its whole matching level should be the worst of each tuple elements. https://github.com/D-Programming-Language/dmd/commit/4cc9491baabd8936933ff6b338e9a9c3a919735f Merge pull request #709 from 9rnsr/fix6208_for_tuple fix Issue 6208 with tuple parameter deduction in IFTI.