[Issue 21275] New: Overload resolution bypasses private access
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 25 14:06:47 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21275
Issue ID: 21275
Summary: Overload resolution bypasses private access
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: 60rntogo at gmail.com
If I define the following module:
---
module foo;
struct Foo
{
import std : writeln;
private int _x;
private ref int x() return
{
writeln("ref int");
return _x;
}
int x() const
{
writeln("int");
return _x;
}
}
---
and in another module:
---
void main()
{
import std : writeln;
import foo : Foo;
auto f = Foo();
f.x = 3;
writeln(f);
}
---
then the program prints
---
ref int
Foo(3)
---
so I have gained access to private method x and member _x.
--
More information about the Digitalmars-d-bugs
mailing list