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

template mixins allows to declare duplicates #18876

Open
dlangBugzillaToGithub opened this issue Aug 31, 2014 · 1 comment
Open

template mixins allows to declare duplicates #18876

dlangBugzillaToGithub opened this issue Aug 31, 2014 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Temtaime (@Temtaime) reported this on 2014-08-31T11:07:45Z

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

Description

import std.stdio;

mixin template R() {
	~this() { write(1); }
}

struct S {
	mixin R;

	~this() { write(2); }
}

void main() {
	S s;
}

This code compiles OK and prints 21 when it should NOT.

import std.stdio;

mixin template R() {
	int a = 1;
	void foo() { write(a); }
}

struct S {
	mixin R;

	void bar() { write(a); }

	int a = 2;
}

void main() {
	S s;
	s.foo();
	s.bar();
}

This code also compiles OK and prints 12 when it's strange and bug-prone.
@dlangBugzillaToGithub
Copy link
Author

temtaime commented on 2014-09-01T11:50:45Z

There's one another issue.

mixin template R() {
	void foo() { writeln(1); }
	void foo() { writeln(2); }
}

struct S {
	mixin R;
}

void main() {
	S s;
}

This code compiles OK, but linker error.

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