[Issue 16610] New: Error: function fun (Bar bar) is not callable using argument types (Bar)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Oct 12 16:17:00 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16610

          Issue ID: 16610
           Summary: Error: function fun (Bar bar) is not callable using
                    argument types (Bar)
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: timothee.cour2 at gmail.com

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`

--


More information about the Digitalmars-d-bugs mailing list