Bug 4523 – [tdpl] .remove method for Associative Arrays returns void in all cases
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-07-27T18:13:00Z
Last change time
2012-01-08T22:51:08Z
Keywords
diagnostic, patch, wrong-code
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2010-07-27T18:13:49Z
Example code errors out due to the .remove method returning void. This method should return boolean true if the key was in the associative array, or false otherwise:
void main() {
int[string] array = ["test":0, "test2":1];
bool found = array.remove("test");
bool notfound = array.remove("nothing");
}
Errors:
assoc_test.d(6): Error: expression array TOK44 "test" is void and has no value
assoc_test.d(7): Error: expression array TOK44 "nothing" is void and has no value
Comment #1 by andrej.mitrovich — 2010-07-27T18:16:27Z
(In reply to comment #0)
> Example code errors out due to the .remove method returning void. This method
> should return boolean true if the key was in the associative array, or false
> otherwise:
>
> void main() {
> int[string] array = ["test":0, "test2":1];
>
> bool found = array.remove("test");
> bool notfound = array.remove("nothing");
> }
>
> Errors:
> assoc_test.d(6): Error: expression array TOK44 "test" is void and has no value
> assoc_test.d(7): Error: expression array TOK44 "nothing" is void and has no
> value
I forgot to add that TDPL states this on page 116.
Comment #2 by clugdbug — 2010-07-27T21:26:19Z
Also TOKxxx should never appear in any error message.
Comment #3 by andrej.mitrovich — 2010-12-22T11:45:22Z
The TOKxxxx messages are gone in 2.051, but AA's remove method still returns void.