Bug 15734 – Need this for map

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-02-28T21:47:38Z
Last change time
2020-03-21T03:56:35Z
Assigned to
No Owner
Creator
Temtaime

Comments

Comment #0 by temtaime — 2016-02-28T21:47:38Z
import std.algorithm; class S { int foo(int a) { return a; } void test() { [ 1, 2, 3 ].map!foo; } } Error: this for foo needs to be type S not type MapResult!(foo, int[]) changing foo to (a => foo(a)) makes it compileable
Comment #1 by k.hara.pg — 2016-03-10T12:55:21Z
Since 2.030 to 2.070, all versions fail to compile the code. Which version has succeed to compile with?
Comment #2 by temtaime — 2016-03-10T14:30:51Z
Hmmm, i though it was combpilable some time ago OK, not a regression then
Comment #3 by b2.temp — 2017-01-15T23:02:03Z
foo is a member function but map takes an alias to a function that must be known at compile time. change definition to static int foo(int a) { return a; } and it works