Bug 4818 – Taking address of shared member function -> unshared delegate
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-09-05T08:34:00Z
Last change time
2011-06-16T00:13:35Z
Assigned to
nobody
Creator
dsimcha
Comments
Comment #0 by dsimcha — 2010-09-05T08:34:42Z
class Foo {
shared void bar() {}
}
void main() {
shared(void delegate()) d;
auto foo = new Foo;
d = &foo.bar;
}
class Foo {
shared void bar() {}
}
void main() {
shared(void delegate()) d;
auto foo = new Foo;
d = &foo.bar;
}
Error: cannot implicitly convert expression (&foo.bar) of type void
delegate() to shared(void delegate())
But this compiles:
class Foo {
void bar() {}
}
void main() {
shared(void delegate()) d;
auto foo = new Foo;
d = &foo.bar;
}
Comment #1 by yebblies — 2011-06-16T00:13:35Z
With dmd 2.053 this prints:
testx.d(9): Error: cannot implicitly convert expression (&foo.bar) of type void
delegate() shared to shared(void delegate())
Which shows the delegate is being typed correctly.
shared(void delegate()) is not the same type as shared(void delegate() shared)