digitalmars.D.learn - Weird error on nested map
- "Simen kjaeraas" <simen.kjaras gmail.com> Jun 27 2010
- Philippe Sigaud <philippe.sigaud gmail.com> Jun 27 2010
auto fn1 = ( string s ) {
return s;
};
auto fn2 = ( string s ) {
return map!fn1( [""] );
};
auto idirs = map!fn2( [""] );
The above code gives the following errors:
foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct
Map cannot be a field
foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct
Map cannot be a field
As far as I can see, this has to do with struct rules, but I can't see
how to fix it. Should I file this in bugzilla?
--
Simen
Jun 27 2010
--0016e6dd95804e845a048a046e86 Content-Type: text/plain; charset=ISO-8859-1 On Sun, Jun 27, 2010 at 10:11, Simen kjaeraas <simen.kjaras gmail.com>wrote:auto fn1 = ( string s ) { return s; }; auto fn2 = ( string s ) { return map!fn1( [""] ); }; auto idirs = map!fn2( [""] ); The above code gives the following errors: foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct Map cannot be a field foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct Map cannot be a field As far as I can see, this has to do with struct rules, but I can't see how to fix it. Should I file this in bugzilla?
means the function you passed to (the outer) Map is not correct, be it a template that has trouble instantiating, a type mismatch or some frame pointer that got lost. In your case, I guess there is a bug somewhere concerning the passing around of delegates. If you get rid of delegates (which is not what you want, I know), it works: string fn1(string s) { return s;} auto fn2(string s) { return map!fn1([""]);} void main() { auto idirs = map!fn2([""]); // works. } I tried defining fn1 inside fn2, but it does not work. Too bad. Philippe --0016e6dd95804e845a048a046e86 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Sun, Jun 27, 2010 at 10:11, Simen kjaeraas <s= pan dir=3D"ltr"><<a href=3D"mailto:simen.kjaras gmail.com">simen.kjaras = gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style= =3D"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); p= adding-left: 1ex;"> auto fn1 =3D ( string s ) {<br> =A0 =A0 =A0 =A0return s;<br> };<br> <br> auto fn2 =3D ( string s ) {<br> =A0 =A0 =A0 =A0return map!fn1( [""] );<br> };<br> <br> auto idirs =3D map!fn2( [""] );<br> <br> The above code gives the following errors:<br> foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct<br> Map cannot be a field<br> foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct<br> Map cannot be a field<br> <br> As far as I can see, this has to do with struct rules, but I can't see<= br> how to fix it. Should I file this in bugzilla?<br><br></blockquote><div><br=I've had this particular error dozens of time :-(=A0=A0 Most of the ti=
it a template that has trouble instantiating, a type mismatch or some frame= pointer that got lost.<br> In your case, I guess there is a bug somewhere concerning the passing aroun= d of delegates. If you get rid of delegates (which is not what you want, I = know), it works:<br><br>string fn1(string s) { return s;}<br>auto fn2(strin= g s) { return map!fn1([""]);}<br> <br>void main()<br>{<br>=A0=A0=A0 auto idirs =3D map!fn2([""]); /= / works.<br>}<br><br>I tried defining fn1 inside fn2, but it does not work.= Too bad.<br><br><br>Philippe<br><br><br><br></div></div> --0016e6dd95804e845a048a046e86--
Jun 27 2010








Philippe Sigaud <philippe.sigaud gmail.com>