Skip to content

Mention type indifference for mixin name conflicts #3103

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions spec/template-mixin.dd
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ $(H2 $(LNAME2 mixin_scope, Mixin Scope))

$(P The declarations in a mixin are placed in a nested scope and then
$(SINGLEQUOTE imported) into the surrounding
scope. If the name of a declaration in a mixin is the same
as a declaration in the surrounding scope, the surrounding declaration
scope. If the name of a symbol in a mixin is the same
as the name of a symbol in the surrounding scope – also with different
symbol types or parameter lists – then the surrounding declaration
overrides the mixin one:)

------
Expand All @@ -209,6 +210,15 @@ mixin template Foo()
{
int x = 5;
int y = 5;
int z(int n, int m)
{
return n*m;
}
}

int z(int n)
{
return n;
}

$(CODE_HIGHLIGHT mixin Foo;)
Expand All @@ -218,11 +228,12 @@ void test()
{
writefln("x = %d", x); // prints 3
writefln("y = %d", y); // prints 3
writefln("z(%d, %d) = %d", 11, 13, z(11, 13)); // error, takes only one parameter
}
------

$(P If two different mixins are put in the same scope, and each
define a declaration with the same name, there is an ambiguity
$(P If two different mixins are put in the same scope, and both
define a symbol with the same name, there is an ambiguity
error when the declaration is referenced:)

------
Expand Down