Bug 16610 – Error: function fun (Bar bar) is not callable using argument types (Bar)

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-10-12T23:17:00Z
Last change time
2018-01-02T17:04:50Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Timothee Cour

Comments

Comment #0 by timothee.cour2 — 2016-10-12T23:17:00Z
dmd can produce uncomprehensible error messages such as: Error: function fun (Bar bar) is not callable using argument types (Bar) Or variants of this: ``` Error: template std.typecons.Nullable!(Bar).Nullable.opAssign cannot deduce function from argument types !()(Bar) ``` (from https://github.com/msoucy/dproto/issues/99) The problem is that `Bar` and `Bar`, although referring to 2 different types, have the same name. This can occur when defined inside a template, eg: ``` template baz(string Tname, string file_protodef){ enum protodef=import(file_protodef); import dproto.dproto; mixin ProtocolBufferFromString!protodef; mixin("alias baz="~Tname~";"); } ``` The fix would be to fully qualify the name `Bar` when possible, or prefix it with a compiler generated string representing context as done for lambdas, eg: `__context142.Bar` vs `__context143.Bar`
Comment #1 by nick — 2018-01-02T17:04:50Z
*** This issue has been marked as a duplicate of issue 9631 ***