www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - assocArray.remove() gives strange error

reply Mariusz =?utf-8?q?Gliwi=C5=84ski?= <alienballance gmail.com> writes:
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: quoted-printable

When i compile:
<code>type[key2][key1] assocArray1;
assocArray1[key1].remove(key2);</code>

everything is ok, but building
<code>type[key2][key1] assocArray1;
return (assocArray1[key1].remove(key2));</code>

gives
<code>dmd: expression.c:817: void expToCBuffer(OutBuffer*, HdrGenState*,=20
Expression*, PREC): Assertion `pr !=3D PREC_zero' failed.</code>

while the book states it should return bool, which typeof() supports

Digital Mars D Compiler v2.049
Copyright (c) 1999-2010 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html

Sincerely,
Mariusz Gliwi=C5=84ski
Dec 23 2010
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Fri, 24 Dec 2010 00:58:37 -0500, Mariusz GliwiƄski  
<alienballance gmail.com> wrote:

 When i compile:
 <code>type[key2][key1] assocArray1;
 assocArray1[key1].remove(key2);</code>

 everything is ok, but building
 <code>type[key2][key1] assocArray1;
 return (assocArray1[key1].remove(key2));</code>

 gives
 <code>dmd: expression.c:817: void expToCBuffer(OutBuffer*, HdrGenState*,
 Expression*, PREC): Assertion `pr != PREC_zero' failed.</code>

 while the book states it should return bool, which typeof() supports

 Digital Mars D Compiler v2.049
 Copyright (c) 1999-2010 by Digital Mars written by Walter Bright
 Documentation: http://www.digitalmars.com/d/2.0/index.html

Part of this a compiler error, the clue is that it's expression.c. Looks like it was fixed. http://d.puremagic.com/issues/show_bug.cgi?id=4914 It was fixed in 2.050. Now the error is: Error: cannot implicitly convert expression ... of type void to bool Here is the relevant report for that: http://d.puremagic.com/issues/show_bug.cgi?id=4523 -Steve
Dec 27 2010