Bug 16328 – shared-unshared method collision for templated methods

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2016-07-27T19:51:32Z
Last change time
2024-12-13T18:49:14Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
hbaelx
Moved to GitHub: dmd#19165 →

Comments

Comment #0 by hbaelx — 2016-07-27T19:51:32Z
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.
Comment #1 by robert.schadek — 2024-12-13T18:49:14Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19165 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB