Bug 12043 – opCall can only be used with IFTI and cannot be explicitly instantiated

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-30T09:54:33Z
Last change time
2024-12-13T18:16:31Z
Assigned to
No Owner
Creator
rswhite4
Moved to GitHub: dmd#18768 →

Comments

Comment #0 by rswhite4 — 2014-01-30T09:54:33Z
This fails with: Error: template instance f!float f is not a template declaration, it is a variable ---- import std.stdio; struct F { T opCall(T = int)(int a, int b, int c) { return cast(T)(a * b * c); } } void main() { F f; int i = f(3,4,5); float f_ = f!float(6, 7, 8); } ---- I don't see why it shouldn't work.
Comment #1 by andrej.mitrovich — 2014-01-30T10:00:00Z
I've reworded the title a little bit.
Comment #2 by rswhite4 — 2014-01-30T10:02:55Z
(In reply to comment #0) > This fails with: > Error: template instance f!float f is not a template declaration, > it is a variable > > ---- > import std.stdio; > > struct F { > T opCall(T = int)(int a, int b, int c) { > return cast(T)(a * b * c); > } > } > > void main() { > F f; > int i = f(3,4,5); > float f_ = f!float(6, 7, 8); > } > ---- > > I don't see why it shouldn't work. Thanks, my english is limited... :)
Comment #3 by rswhite4 — 2014-01-30T13:31:03Z
(In reply to comment #0) > This fails with: > Error: template instance f!float f is not a template declaration, > it is a variable > > ---- > import std.stdio; > > struct F { > T opCall(T = int)(int a, int b, int c) { > return cast(T)(a * b * c); > } > } > > void main() { > F f; > int i = f(3,4,5); > float f_ = f!float(6, 7, 8); > } > ---- > > I don't see why it shouldn't work. It also applies to opIndex and so probably to all op* methods: ---- struct F { T opIndex(T = int)(int index) { return cast(T) 0; } } void main() { F f; f[42]; f!int[42]; /// fails } ----
Comment #4 by robert.schadek — 2024-12-13T18:16:31Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18768 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB