1943 – Templates can't take function pointer parameters

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1943 - Templates can't take function pointer parameters
Summary: Templates can't take function pointer parameters
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid, spec
Depends on:
Blocks:
Reported: 2008年03月25日 14:32 UTC by Russ Lewis
Modified: 2015年06月09日 01:14 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Russ Lewis 2008年03月25日 14:32:09 UTC
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 Daniel Keep 2009年07月12日 21:55:06 UTC
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.


AltStyle によって変換されたページ (->オリジナル) /