You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's what I got so far:
The coercion of values happens in coerceGoValue, in apply.go.
There are a couple special cases (for Slice and Func) and a default case that should handle the rest.
We don't seem to handle pointers, which is the case for this particular issue (*lang.BigInt). This can be easily fixed by checking for reflect.Ptr in the default case.
BigInt, BigDecimal, etc are wrappers of their native types i.e. big.Int, big.Decimal respectively.
This causes the Convert function of reflect to not be able to know how to convert the type to, for example, int64.
These wrapper types have internal methods for converting to types such as Int64(), String(), etc.
A way of going around this issue would be to use something like MethodByName and check for methods with the same name as the targetType. This is a bit ugly, and we have the issue that MethodByName is case sensitive, although that could be easily fixed by getting the native type as a string and doing .Title() to it or with a helper function.
I have a working solution based on these points, but I recognize that it's an ugly hack. Let me know your thoughts.
Thanks for taking a look! I'm afk right now so I may be mistaken on some of this, but I think the ideal solve here is a dedicated Go implementation of Repeat for BigInt that supports the arbitrarily large count that it implies. When in doubt, refer to clojure's source for this: both core.clj and the core Java classes.
Activity
mateodif commentedon Nov 13, 2023
I've been looking into this issue.
Here's what I got so far:
The coercion of values happens in
coerceGoValue, inapply.go.defaultcase that should handle the rest.*lang.BigInt). This can be easily fixed by checking forreflect.Ptrin the default case.BigInt,BigDecimal, etc are wrappers of their native types i.e. big.Int, big.Decimal respectively.Convertfunction ofreflectto not be able to know how to convert the type to, for example, int64.Int64(),String(), etc.A way of going around this issue would be to use something like
MethodByNameand check for methods with the same name as thetargetType. This is a bit ugly, and we have the issue thatMethodByNameis case sensitive, although that could be easily fixed by getting the native type as a string and doing.Title()to it or with a helper function.I have a working solution based on these points, but I recognize that it's an ugly hack. Let me know your thoughts.
jfhamlin commentedon Nov 14, 2023
Thanks for taking a look! I'm afk right now so I may be mistaken on some of this, but I think the ideal solve here is a dedicated Go implementation of Repeat for BigInt that supports the arbitrarily large count that it implies. When in doubt, refer to clojure's source for this: both core.clj and the core Java classes.
jfhamlin commentedon Nov 14, 2023
Looks like my memory on this was dodgy re Clojure's support for Repeat, and you're probably on the right track here!