Overview
| Artifact ID: | 3c3c129373a4a88a38c27b76bf5cd68e3bc67adfc8958a6eea41d37a2610a9f5 |
|---|---|
| Ticket: | 3598385fffffffffffffffffffffffffffffffff
[dict exists] doesn't produce an error for non-dict values |
| User & Date: | aspect on 2018-05-21 00:23:35 |
Changes
- closedate changed to: "2458259.51638589"
- closer changed to: "aspect"
- icomment:
+1 error. I don't think the cases should be distinguished: [dict get {a b} a b] is exactly the same category of error. Considering it a bug for [3475264] was too hasty. Dictionaries with non-dict leaves are only recursive structures until you hit a leaf - applying too many keys with [dict exists] is just as wrong as doing so with [dict set] or [dict get]. Let me emphasise: an arbitrarily-shaped tree with values at the leaves is not simply represented in a dict, since those values may accidentally look like dicts. We all know this, but I've seen myself and others stumble on it many times. I think [3475264] came from the same mistaken place, and I struggle to imagine correct code that could be rendered incorrect by an error being raised in that case. In [3475264] ticket dkf observed: > based on the current documentation it should not be throwing errors which is false: the manual prescribes only when [dict exists] returns true. The current situation is asymmetric and surprising on at least two counts: 1. Every other dict subcommand raises an error when asked to treat a non-dict value as a dict. 2. the (implicit but obvious) identity is broken: [dict exists $d $k ...] == [dict exists $d $k] && [dict exists [dict get $d $k] ...] as a user I expect this because: [dict get $d $k ...] == [dict get [dict get $d $k] ...] 3. {[dict exists $d {*}$k] == 0} doesn't tell me that [dict set $d {*}$k] will succeed - login: "aspect"
- mimetype: "text/x-fossil-wiki"