Thread overview
[Issue 6598] New: Function literals are rejected by structure initializers as non-constant
Sep 03, 2011
Maksim Zholudev
Apr 27, 2012
SomeDude
Apr 28, 2012
Maksim Zholudev
September 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6598

           Summary: Function literals are rejected by structure
                    initializers as non-constant
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: maximzms@gmail.com


--- Comment #0 from Maksim Zholudev <maximzms@gmail.com> 2011-09-03 06:30:41 PDT ---
***** 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).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6598


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-27 14:20:37 PDT ---
Compiles with 2.059 Win32

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6598


Maksim Zholudev <maximzms@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Maksim Zholudev <maximzms@gmail.com> 2012-04-28 04:16:19 PDT ---
Compiles with DMD64 D Compiler v2.059 on 64-bit Linux

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------