Bug 6598 – Function literals are rejected by structure initializers as non-constant
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2011-09-03T06:30:00Z
Last change time
2012-04-28T04:16:19Z
Assigned to
nobody
Creator
maximzms
Comments
Comment #0 by maximzms — 2011-09-03T06:30:41Z
***** Description: *****
The following code will not compile with DMD64 D Compiler v2.055 (from github):
----------
auto func = function double(double x) {return x;}; // OK
struct Foo {double function(double) func;}
auto f1 = Foo(function double(double x) {return x;}); // Error
void main()
{
auto f2 = Foo(function double(double x) {return x;}); // OK
}
----------
Error: non-constant expression cast(double function(double))function pure nothrow @safe double(double x)
----------
Compilation fails only if the initializer is placed outside main function.
***** Suspecting: *****
This can be related to Issue 2634 (fixed).
Comment #1 by lovelydear — 2012-04-27T14:20:37Z
Compiles with 2.059 Win32
Comment #2 by maximzms — 2012-04-28T04:16:19Z
Compiles with DMD64 D Compiler v2.059 on 64-bit Linux