D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19536 - Cannot access private template argument
Summary: Cannot access private template argument
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-01 14:18 UTC by Victor Porton
Modified: 2024-12-13 19:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Victor Porton 2019-01-01 14:18:04 UTC
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.)
Comment 1 dlangBugzillaToGithub 2024-12-13 19:01:49 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19522

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB