Protected module members -- regression?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Oct 29 10:47:11 UTC 2018


On Monday, October 29, 2018 4:37:33 AM MDT Mike Parker via Digitalmars-d 
wrote:
> I've long had it in my mind to do a sort of "D for C++/Java/C#"
> programmers sort of series on the blog. Inspired by the recent
> conversation about private-to-the-module, I started one on that
> topic. Then I encountered this:
>
> ```
> module a;
>
> protected int wrong;
> ```
>
> ```
> module b;
> import std.stdio;
> import a;
>
> int main() { writeln(wrong); }
> ```
>
> I've always understood that protected module members are illegal.
> The docs explicitly say so. Yet the declaration of `wrong`
> compiles. Instead, trying to use it results in the deprecation
> message about symbol visibility that was added a couple years
> back when access modifiers were incorporated into symbol lookup.
>
> I assume this is a regression and filed it as such [1], but I'm
> curious if the compiler has ever actually complained about
> protected module members.
>
> [1] https://issues.dlang.org/show_bug.cgi?id=19340

Really, if you want to know, the surest way is to test older versions of the
compiler. Someone may post that they remember it being an error in the past,
but I doubt that they could give you a compiler version if they did, and
honestly, it's the sort of thing that most of us would never have tried,
since it makes no sense to use protected outside of a class.

- Jonathan M Davis





More information about the Digitalmars-d mailing list