|
2020-11-16
| ||
| 14:19 | • Closed ticket [d22ad20205]: "dict unset d key subkey" fails if key doe... artifact: 69d5a81801 user: oehhar | |
| 14:19 | • Ticket [d22ad20205]: 4 changes artifact: 393f75ecb9 user: oehhar | |
|
2018-07-02
| ||
| 11:04 | • Ticket [d22ad20205]: 3 changes artifact: 110ef0dbb8 user: sebres | |
| 11:03 | • Ticket [d22ad20205]: 3 changes artifact: 823f434d5a user: sebres | |
| 10:24 | • New ticket [d22ad20205]. artifact: 87f9039ad3 user: oehhar | |
"dict unset d key subkey" fails if key does not exist
Closed / Fixedd22ad202055093292992c6aea053188f8b3d4abeCreated 8 years agoUpdated 6 years ago
Descriptionwiki2018-07-02 10:24:28
If a dictionary key is unset, there is no error, if it does not exist:
% set d {}
% dict unset d a
There is an error raised, if a key on the path of the subkey does not exist:
% set d {}
% dict unset d a b
key "a" not known in dictionary
IMHO this is inconsistent and should not rise an error.
At least the documentation should write about error behaviour.
I can understand, that an error is raised, if the (sub)dict is not a valid dict.
% set d {1}
% dict unset d a
missing value to go with key
% set d {a 1}
% dict unset d a b
missing value to go with key
sebreswiki2018-07-02 11:03:13
Still worse (as regards the inconsistency), it does not produce any error if dictionary self (variable) does not exists:
% unset -nocomplain d
% catch { dict unset d a }
0
So I'm agree with Harald's conclusion, the `dict unset` must not produce an error if sub-key does not exists also.
sebres Ticket [d22ad20205]: 3 changes
[History diff]2018-07-02 11:04:59
oehharwiki2020-11-16 14:19:30
Tested again with tcl8.6.10. Is fixed. Thank you, Harald
oehhar Closed ticket [d22ad20205].
[History diff]2020-11-16 14:19:43
Log in (anonymous is fine) to add a comment.