[Issue 12408] New: map does not like inout
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 18 18:21:03 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12408
Summary: map does not like inout
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: lt.infiltrator at gmail.com
--- Comment #0 from Infiltrator <lt.infiltrator at gmail.com> 2014-03-18 18:20:59 PDT ---
http://dpaste.dzfl.pl/cd03223f4472
----------------------------------------------------
import std.algorithm : map;
class L {
auto fun(const S s) inout nothrow pure @safe {
if(point[0] is s)
return point[1];
else
return point[0];
}
this(S a, S b) {
point = [a, b];
}
S[2] point;
}
class S {
@property auto foo() inout nothrow pure @safe {
return arr.map!(e => e.fun(this));
}
L[] arr;
}
void main() { }
----------------------------------------------------
Fails to compile:
/opt/compilers/dmd2/include/std/algorithm.d(438): Error: variable
f922.S.foo.MapResult!(__lambda1, inout(L)[]).MapResult._input only parameters
or stack based variables can be inout
/opt/compilers/dmd2/include/std/algorithm.d(390): Error: template instance
f922.S.foo.MapResult!(__lambda1, inout(L)[]) error instantiating
/d556/f922.d(18): instantiated from here: map!(inout(L)[]) /d556/f922.d(18):
Error: template instance f922.S.foo.map!((e) => e.fun(this)).map!(inout(L)[])
error instantiating /d556/f922.d(18): Error: template std.algorithm.map cannot
deduce function from argument types !((e) => e.fun(this))(inout(L[])),
candidates are: /opt/compilers/dmd2/include/std/algorithm.d(375):
std.algorithm.map(fun...) if (fun.length >= 1)
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list