 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Jun 16, 2010 1:36 am
[3.19d] #ADD fails to create new keys on nested lists |
Stress testing! I don't usually use #ADD, but here's some tests:
| Quote: |
#add test1 5
#show @test1
|
Very nicely creates a new variable with the value I expect.
| Quote: |
#addkey test2 a 2
#add test2.b 5
#show @test2
|
And it even creates a new key/value pair on a simple db variable!
| Quote: |
#addkey test2.c alpha 2
#show @test2
#add test2.c.alpha 3
#show @test2
|
#ADD correctly handles nested lists that already exist. But...
| Quote: |
#add test2.c.beta 5
#show @test2
|
It fails to add a new key to a nested list if the key doesn't already exist. Instead, it replaces the entire value with the number. |
|
Last edited by Rahab on Wed Jun 16, 2010 2:06 am; edited 1 time in total |
|
|
 |
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
Posted: Wed Jun 16, 2010 1:58 am |
I assume that's a typo in the last one? Seems like it should be #show @test2.
|
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Jun 16, 2010 2:06 am |
Yeah, thanks. Corrected now.
|
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Jun 16, 2010 2:17 am |
Yep, good catch. My guess is that you'll find a lot of stuff like this. While I did spend some time to support nested lists, I probably don't handle "recursive" nested lists in all places. In other words, stuff like var.key and var.2 will work, but any further chaining won't work. I think this probably applies to all commands (#additem, #addkey, etc) and not just #add, but it would be interesting to test.
I probably won't fix #add since #add is mostly deprecated and the correct way to do it is really:
| Code: |
| test2.c.beta 5 = (@test2.c.beta + 5) |
although that won't properly create the variable either and will end up doing a string concat instead of a numeric add.
But report anything else along these lines. If it effects more than #add then it might be worth looking for a fix. Doing recursive variable creation is just a bit of a pain. |
|
|
|
 |
|
|
|