Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address of private method from another module can be taken #18694

Open
dlangBugzillaToGithub opened this issue Oct 12, 2013 · 2 comments
Open

Comments

@dlangBugzillaToGithub
Copy link

rswhite4 reported this on 2013-10-12T12:20:03Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=11234

CC List

Description

A.d:
----
import B;

class Foo {
public:
	void call(Bar b) {
		void delegate(int) dg = &b.test;
		dg(42);
	}
}

void main() {
	Bar b = new Bar();
	Foo f = new Foo();
	f.call(b);
}
----

B.d:
----
import std.stdio;

class Bar {
private:
	void test(int id) {
		writeln("Bar called with ", id);
	}
}
----

Output: Bar called with 42
But should be rejected.
@dlangBugzillaToGithub
Copy link
Author

andrej.mitrovich (@AndrejMitrovic) commented on 2013-10-12T12:23:34Z

Reduced a little bit:

-----
module a;
import b;

void main()
{
    auto s = S();
    auto f = &s.f;  // no error
    f();  // no error

    auto sf = &S.sf;  // error
}
-----

-----
module b;
struct S
{
    private void f() { }
    private static void sf() { }
}
-----

@dlangBugzillaToGithub
Copy link
Author

rswhite4 commented on 2013-10-12T12:29:08Z

I'm unsure, but maybe we should also classify this as major because it breaks the protection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant