[Issue 16328] New: shared-unshared method collision for templated methods
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 27 12:51:32 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16328
Issue ID: 16328
Summary: shared-unshared method collision for templated methods
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: hbaelx at hotmail.com
The following program perfectly reproduces this error:
-----
import std.stdio;
struct Foo
{
void ping()
{
writeln("Regular ping");
}
void ping() shared
{
writefln("Shared ping");
}
void pang(T)()
{
writeln("Regular pang with " ~ T.stringof);
}
void pang(T)() shared
{
writeln("Shared pang with " ~ T.stringof);
}
void bug()
{
ping(); // OK, calls regular ping()
pang!int(); /* both.d(28): Error: both.Foo.pang called with argument
types () matches both:
both.d(15): both.Foo.pang!int.pang()
and:
both.d(20): both.Foo.pang!int.pang() */
this.pang!int(); // OK, workaround to call regular pang!int()
}
void bug() shared
{
ping(); // OK, calls shared ping();
pang!int(); /* Error: both.Foo.pang called with argument types ()
matches both:
both.d(15): both.Foo.pang!int.pang()
and:
both.d(20): both.Foo.pang!int.pang() */
this.pang!int(); // OK, workaround to call shared pang!int()
}
}
void main()
{
auto a = Foo();
a.bug();
auto b = shared Foo();
b.bug();
}
------
Apparently, the compiler cannot tell between shared and non-shared methods when
these are templated. Happens for both struct and classes.
--
More information about the Digitalmars-d-bugs
mailing list