Bug 4812 – Basic template syntax is rejected

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-09-04T12:06:00Z
Last change time
2012-12-09T08:43:20Z
Keywords
rejects-valid
Assigned to
nobody
Creator
rayerd.wiz

Comments

Comment #0 by rayerd.wiz — 2010-09-04T12:06:11Z
import std.stdio; template foo(T) { T foo(T t) { return t + 1; } } void main() { writeln(foo(1)); // OK writeln(foo!(int)(1)); // OK writeln(foo!(int).foo(1)); // NG } bug_d.d(12): Error: expected 1 function arguments, not 0 bug_d.d(12): Error: no property 'foo' for type 'int'
Comment #1 by andrej.mitrovich — 2012-12-09T08:43:20Z
This is a case of the eponymous template. foo!(int) becomes an alias to the inner foo function.