Bug 16957 – access function from inside template with same name

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-12-08T00:21:39Z
Last change time
2024-12-13T18:50:55Z
Assigned to
No Owner
Creator
John Colvin
Moved to GitHub: dmd#19212 →

Comments

Comment #0 by john.loughran.colvin — 2016-12-08T00:21:39Z
auto a() { return 1; } enum a() = .a(); enum b = a!(); test.d(2): Error: none of the overloads of 'a' are callable using argument types (), candidates are: test.d(1): test.a() test.d(3): Error: template instance test.a!() error instantiating
Comment #1 by john.loughran.colvin — 2016-12-08T00:40:02Z
a related problem that seems likely to have the same root cause: T[N] bar(T, size_t N)(T[N] a) { return a; } alias foo = bar; // remove this line and everything's ok. template foo(alias r) { enum s = bar(r); pragma(msg, typeof(s), " ", s); enum foo = s; } enum x = foo!([0,1,2]); output: int[3] [0, 1, 2] test.d(15): Error: cannot infer type from template instance foo!([0, 1, 2])
Comment #2 by john.loughran.colvin — 2016-12-08T12:54:00Z
template a(alias b) { alias T = typeof(b); auto a(T ret) { return ret; } } auto a(T, size_t N)(T[N] a) {} // breaks // auto a(T)(T[] a) {} // OK void main() { int x; auto b = a!(x); } test.d(5): Error: undefined identifier 'T' test.d(16): Error: cannot infer type from template instance a!(x)
Comment #3 by robert.schadek — 2024-12-13T18:50:55Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19212 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB