[Issue 3235] [tdpl] Function literals must be deduced as "function" or "delegate"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 18 20:05:44 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=3235


Andrei Alexandrescu <andrei at metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|TDPL: Function literals     |[tdpl] Function literals
                   |must be deduced as          |must be deduced as
                   |"function" or "delegate"    |"function" or "delegate"


--- Comment #6 from Andrei Alexandrescu <andrei at metalanguage.com> 2011-12-18 20:05:41 PST ---
The following example is in TDPL:

unittest
{
  auto f = (int i) {};
  assert(is(f == function));
}

The example fails to compile (it should). Also the following example should
work:

unittest
{
  int a;
  auto f = (int i) { a = i; };
  assert(is(f == delegate));
}

The compiler should automatically infer function or delegate type depending on
the literal's use of local state. The argument against it - people change a
detail in the body of the function and its type changes - is non sequitur.
Changing a literal from 10 to 10.0 also changes its type. Please fix.

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


More information about the Digitalmars-d-bugs mailing list