Bug 5801 – Using typeof() in function header breaks ITFI and default template arguments.

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-03-30T15:55:00Z
Last change time
2011-12-21T05:55:25Z
Keywords
rejects-valid
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2011-03-30T15:55:34Z
The following program compiles (bar uses a default type for T, baz relies on IFTI): --- void bar(T = double)(int i) {} void baz(T)(int i, T t) {} void main() { bar(2); baz(3, "baz"); } --- But if typeof() is used instead of explicitly specifying int, neither calls to bar and baz work any longer: --- int a; void bar(T = double)(typeof(a) i) {} void baz(T)(typeof(a) i, T t) {} void main() { bar(2); // Does not compile. baz(3, "baz"); // Does not compile. } --- The respective error messages are: Error: template test.bar(T = double) does not match any function template declaration Error: template test.bar(T = double) cannot deduce template function from argument types !()(int) and Error: template test.baz(T) does not match any function template declaration Error: template test.baz(T) cannot deduce template function from argument types !()(int,string). If the template parameter is specified explicitly, however, both of the examples work again: --- int a; void bar(T = double)(typeof(a) i) {} void baz(T)(typeof(a) i, T t) {} void main() { bar!double(2); baz!string(3, "baz"); } --- DMD from Git master at b7133502.
Comment #1 by bearophile_hugs — 2011-03-30T16:31:00Z
Take a look at bug 4413 to see if this is a dupe.
Comment #2 by code — 2011-04-10T14:08:36Z
(In reply to comment #1) > Take a look at bug 4413 to see if this is a dupe. I'm not sure – it's certainly not a direct duplicate, but the root cause might be the same.
Comment #3 by k.hara.pg — 2011-12-21T05:55:25Z
*** This issue has been marked as a duplicate of issue 4413 ***