Bug 6963 – pure/nothrow inference doesn't work for function pointers
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-11-16T20:30:00Z
Last change time
2013-02-05T13:12:40Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2011-11-16T20:30:27Z
void foo(X)(X x)
{}
immutable void function(int) pure bar = &foo!(int);
test.d(7): Error: cannot implicitly convert expression (& foo) of type void fun
ction(int x) to immutable(void function(int) pure)
Incidentally, this code:
immutable nothrow pure bar = &foo!(int);
compiles without error, but bar isn't pure nothrow!
Comment #1 by k.hara.pg — 2011-11-18T02:20:42Z
It doesn't occur if the declarations are in function scope.
void foo(X)(X x) {}
// doesn't work
//immutable void function(int) pure bar1 = &foo!(int);
//immutable nothrow pure bar2 = &foo!(int);
void main()
{
// does work
immutable void function(int) pure bar1 = &foo!(int);
immutable nothrow pure bar2 = &foo!(int);
}