Closed skydread1 closed 1 year ago
I notice we don't have this line of code in stdlib/walk and I tried to update it and recompile but got the same result.
From our notes
There is no
datafy
related error if we do not have optimisation on. The*strongly-typed-invokes*
flags introduced errors concerningdatafy
. Also, we have lessdatafy
errors if we type hint the code.
Reduced to a more minimal reproducing case.
(require '[clojure.core.protocols :as proto]
'[clojure.datafy :refer [datafy]]
'[clojure.walk :as walk])
(defrecord R1 [a]
proto/Datafiable
(datafy [_]
(datafy a)))
(walk/postwalk datafy (->R1 1))
This behaves as you described, fine without *strongly-typed-invokes*
enabled and throws when it is. Likely that MAGIC's more strict notion of type casting is clashing with Clojure's protocol mechanism.
Fixed with 768f6bb9f74a795bbefab43e5d56814e82caa544.
Problem
In case the optimisation flag
magic.flags/*strongly-typed-invokes*
istrue
,clojure.datafy/datafy
for nested records throws an exception when used withclojure.walk/postwalk
.How to reproduce
Let's consider the Clojure code:
In both JVM and CLR, we get the expected result for:
However, calling
datafy
onr2
triggers an error on the CLR:So the error comes from
(walk/postwalk datafy r1)
whenr1
is a vector of records.