Completed
Details
Assignee
UnassignedUnassignedReporter
Sean CorfieldSean CorfieldLabels
Approval
OkPatch
Code and TestPriority
MajorAffects versions
Fix versions
Details
Details
Assignee
Unassigned
UnassignedReporter
Sean Corfield
Sean CorfieldLabels
Approval
Ok
Patch
Code and Test
Priority

Affects versions
Fix versions
Created October 2, 2016 at 1:32 AM
Updated September 14, 2018 at 10:21 PM
Resolved September 14, 2018 at 10:21 PM
This came up on Slack. A naïve implementation of "lispify" to turn vectors into lists used this code:
But when called like this:
It produces this error: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry
My initial reaction was to change the condition to
(and (vector? e) (not (map-entry? e)))
but that still failed, because while walking the hash map, the MapEntry[:a "b"]
was turned into a PersistentVector.At this point, we can switch to using
prewalk
and it works as expected:Now we get the expected result:
This seems unintuitive at best and feels like a bug:
postwalk
should preserve the MapEntry type rather than converting it to a PersistentVector.Cause: The problem seems to be this line https://github.com/clojure/clojure/blob/master/src/clj/clojure/walk.clj#L45:
Proposed: Change to:
This would preserve the type of the subelement.
Patch: clj-2031-w-test-v2.diff
Screened by: Alex Miller