D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15734 - Need this for map
Summary: Need this for map
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-28 21:47 UTC by Temtaime
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Temtaime 2016-02-28 21:47:38 UTC
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 Kenji Hara 2016-03-10 12:55:21 UTC
Since 2.030 to 2.070, all versions fail to compile the code.

Which version has succeed to compile with?
Comment 2 Temtaime 2016-03-10 14:30:51 UTC
Hmmm, i though it was combpilable some time ago
OK, not a regression then
Comment 3 basile-z 2017-01-15 23:02:03 UTC
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