There was a bug in the hash hyper that I fixed (it didn't handle structural recursion, I just integrated the code from the array handling). I still don't think the hash code is correct though, it seems like the full dwim and no dwim paths would end up with the exact same key list (if nothing else, there's no error path which smells very fishy).
The code additions are fairly simple, I basically just added a :@path parameter
that tracked how we got to the current element. I then had 3 variants of the
strings for the 0 element path, 1 element path, and n element path variants,
giving strings of the form:
Structures are of uneven length and not dwimmy. Length 1 vs 2.
Structures are of uneven length and not dwimmy at element 2. Length 1 vs. 2.
Structures are of uneven length and not dwimmy at element [2, cat, 3, 0].
Length 1 vs. 2.
For example:
1,2) >>+<< (3,4,5)
[4, 6, 8]
(1,2,[3]) >>+<< (3,4,[5,6])
Structures are of uneven length and not dwimmy at element 2. Length 1 vs. 2.
(1,2,3,[[4,5], 6]) >>+<< (3,4,5,[[5],[6]])
Structures are of uneven length and not dwimmy at element [3, 0]. Length 2 vs.
1.
(1,2,3,{cat => 1, dog => 2}) >>+<< (3,4,5,{cat => [6], dog => 7})
[4, 6, 8, {"cat" => [7], "dog" => 9}]
(1,2,3,{cat => 1, dog => 2}) >>+<< (3,4,5,{cat => [6,7], dog => 8})
Structures are of uneven length and not dwimmy at element [3, cat]. Length 1
vs. 2.
{cat => [1,2], dog => 2} >>+<< 6
Right hand side is too short and not dwimmy.
(3,4,5,6) >>+<< (1,2,3,{cat => 1, dog => 2})
Left hand side is too short and not dwimmy at element 3.
I currently just have the code printing out a join with ', ' of @path. I
wasn't sure what the proper choice between this and .perl was. Obviously .perl
is more diagnostic-y, but the stringification should result in a shorter error
message that (hopefully) still points the user to the correct element in their
structure. I also don't like using the word element for the multi-depth path,
it doesn't seem accurate. I originally used 'path', but it didn't sound much
better so I unified them.
Hope this helps,
-Tim
metaops.pm
Description: Perl program
