Bug 1943 – Templates can't take function pointer parameters
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-03-25T14:32:00Z
Last change time
2015-06-09T01:14:38Z
Keywords
rejects-valid, spec
Assigned to
nobody
Creator
webmaster
Comments
Comment #0 by webmaster — 2008-03-25T14:32:09Z
dmd 2.012, Linux
dmd rejects code which the spec says should be valid (the spec doesn't mention any limitations to value parameters):
BEGIN CODE
template foo(void function() fp /*TPL...*/) {}
void bar() {}
alias foo!(&bar) a1;
END CODE
BEGIN dmd OUTPUT
test.d(1): Error: arithmetic/string type expected for value-parameter, not void function()
END OUTPUT
BEGIN CODE (2nd manifestation)
template foo(TPL...) {}
void bar() {}
alias foo!(&bar) a1;
END CODE
BEGIN dmd OUTPUT
test.d(3): Error: expression & bar is not a valid template value argument
test.d(3): template instance test.foo!(& bar) error instantiating
END OUTPUT
Comment #1 by daniel.keep+d.puremagic.com — 2009-07-12T21:55:06Z
This has just cropped up on IRC. Either the compiler should be fixed to match the spec, or the spec should be changed to match the compiler's behaviour.
The simplest thing to do would be to change to spec to indicate that only strings, ints and floats are allowed as value parameters.
Comment #2 by github-bugzilla — 2012-01-22T01:03:33Z