Thread overview
[Issue 2775] "private" ignored for templates
Oct 24, 2014
Shachar Shemesh
Oct 24, 2014
Shachar Shemesh
Jun 13, 2015
Adrian Matoga
Feb 16, 2016
Simon Na.
Aug 11, 2019
Mathias LANG
October 24, 2014
https://issues.dlang.org/show_bug.cgi?id=2775

Shachar Shemesh <shachar@shemesh.biz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shachar@shemesh.biz

--
October 24, 2014
https://issues.dlang.org/show_bug.cgi?id=2775

Shachar Shemesh <shachar@shemesh.biz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1                          |D1 & D2
           Severity|normal                      |major

--- Comment #4 from Shachar Shemesh <shachar@shemesh.biz> ---
As of dmd v2.065 (5 and a half years after initial report) this problem is
still open.

Visibility limitation is touted, correctly, as a major language feature in "The D Programming Language". It is designed to prevent bugs and reduce development costs.

As such, I took the liberty to raise the importance to "Major". Since the problem is happening to me on recent DMD, I changed the version to both D1 and D2. Hopefully, this will merit some attention to this bug.

--
June 10, 2015
https://issues.dlang.org/show_bug.cgi?id=2775

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 & D2                     |D2

--
June 13, 2015
https://issues.dlang.org/show_bug.cgi?id=2775

Adrian Matoga <epi@atari8.info> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |epi@atari8.info

--- Comment #5 from Adrian Matoga <epi@atari8.info> ---
Still exists in 2.067.1.

--
February 16, 2016
https://issues.dlang.org/show_bug.cgi?id=2775

Simon Na. <eiderdaus@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eiderdaus@gmail.com

--- Comment #6 from Simon Na. <eiderdaus@gmail.com> ---
In DMD 2.070, the bug still manifests for private template methods. It's fixed for static class functions, and for module-scope functions.

Here's example code that errors out correctly:

    // foo.d
    import std.conv;
    private string func(T)(T t) { return t.to!string; }

    // main.d
    import std.stdio;
    import foo;
    void main() { writeln("hello world " ~ func(4)); }

Error message, as expected:

    main.d(6): Error: module main template foo.func(T)(T t) is private
    main.d(6): Error: function foo.func!int.func is not accessible from module
main

However, if I make a class in foo.d and put the template inside, the code compiles, links, and calls the private function:

    // foo.d
    import std.conv;
    class A {
        private string func(T)(T t) { return t.to!string; }
    }

    // main.d
    import std.stdio;
    import foo;
    void main() { A a = new A(); writeln("hello world " ~ a.func(4)); }

Expected instead: A privacy violation error, as in my first example code.

--
August 11, 2019
https://issues.dlang.org/show_bug.cgi?id=2775

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |pro.mathias.lang@gmail.com
         Resolution|---                         |FIXED

--- Comment #7 from Mathias LANG <pro.mathias.lang@gmail.com> ---
The provided test cases now correctly error out.

--