[Issue 19536] New: Cannot access private template argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 1 14:18:04 UTC 2019


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

          Issue ID: 19536
           Summary: Cannot access private template argument
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: porton at narod.ru

Originally appeared in https://stackoverflow.com/q/53982974/856090

//handled_record.d:

module handled_record;

template CObjects(alias destructor) {
    void f() {
        destructor();
    }
}

//world.d:

module world;

import handled_record;

private void free() { }

alias objects = CObjects!(free);

Compiling:

$ dmd -c *.d
handled_record.d(5): Error: function world.free is not accessible from module
handled_record
world.d(7): Error: template instance `handled_record.CObjects!(free)` error
instantiating

The error disappears if I remove private keyword.

Is it a compiler bug? (In my understanding the alias symbol passed to a
template should be accessible by the template because it is explicitly passed
to the template, even if it is private.)

--


More information about the Digitalmars-d-bugs mailing list