www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Private alias bug.

reply David L. Davis <SpottedTiger yahoo.com> writes:
In the following test code below, "ss" is made to be a private alias, but when
it's imported in, it seems to become public in the module it's imported into
without an error. Logically, I should have to define "ss" with another alias in
order in use in the other module. To me, this looks very much like a bug.

# Privately defined alias done here.
# module printstr;
# private import std.stdio;
#
# private alias .std.stdio ss;
#
# void printstring(in char[] s)
# {
#     ss.writefln("printstring(\"%s\")=\"%s\"", s, s);
# } 

# //--------------------------------------------------------------

# // ss is not defined but used, shouldn't it fail?
# module testalias;
#
# private import std.stdio;
# private import std.string;
# private import printstr;
#
# int main()
# {
#     char[] s = "TEST STRING";
#     // ss is defined as a private alias in printstr,
#     // but it still works here?!? Should it?
#     ss.writefln("tolower(\"%s\")=\"%s\"", s, tolower(s));
#     printstring(s);
#    
#     return 0;
# }

Output:
-------
C:\dmd>dmd testalias.d printstring.d
C:\dmd\bin\..\..\dm\bin\link.exe testalias+printstring,,,user32+kernel32/noi;

C:\dmd>testalias
tolower("TEST STRING")="test string"
printstring("TEST STRING")="TEST STRING"

C:\dmd>

Thanks,
David L.


-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------

MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Jun 16 2005
parent Thomas Kuehne <thomas-dloop kuehne.this-is-spam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David L  Davis schrieb am Thu, 16 Jun 2005 11:13:11 +0000 (UTC):
 In the following test code below, "ss" is made to be a private alias, but when
 it's imported in, it seems to become public in the module it's imported into
 without an error. Logically, I should have to define "ss" with another alias in
 order in use in the other module. To me, this looks very much like a bug.

 # Privately defined alias done here.
 # module printstr;
 # private import std.stdio;
 #
 # private alias .std.stdio ss;
 #
 # void printstring(in char[] s)
 # {
 #     ss.writefln("printstring(\"%s\")=\"%s\"", s, s);
 # } 

 # //--------------------------------------------------------------

 # // ss is not defined but used, shouldn't it fail?
 # module testalias;
 #
 # private import std.stdio;
 # private import std.string;
 # private import printstr;
 #
 # int main()
 # {
 #     char[] s = "TEST STRING";
 #     // ss is defined as a private alias in printstr,
 #     // but it still works here?!? Should it?
 #     ss.writefln("tolower(\"%s\")=\"%s\"", s, tolower(s));
 #     printstring(s);
 #    
 #     return 0;
 # }

 Output:
 -------
 C:\dmd>dmd testalias.d printstring.d
 C:\dmd\bin\..\..\dm\bin\link.exe testalias+printstring,,,user32+kernel32/noi;

 C:\dmd>testalias
 tolower("TEST STRING")="test string"
 printstring("TEST STRING")="TEST STRING"
Added to DStress as http://dstress.kuehne.cn/nocompile/a/alias_25_A.d http://dstress.kuehne.cn/nocompile/a/alias_25_B.d http://dstress.kuehne.cn/nocompile/a/alias_25_C.d http://dstress.kuehne.cn/run/a/alias_25_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCsymN3w+/yD4P9tIRAj2AAJ9VQq9FjIt40Zl36ikejlhWpnXZxwCaApoa UN5izLcC0Kk0K79AMiNnNks= =DBYn -----END PGP SIGNATURE-----
Jun 17 2005