cognitect / transit-cljs

Transit for ClojureScript
http://transit-format.org
Apache License 2.0
323 stars 20 forks source link

Bug: read-handler with multiple arities breaks #49

Open galdre opened 5 years ago

galdre commented 5 years ago

Description

If a read-handler function has more than one arity, transit-cljs/read attempts to call the incorrect arity when deserializing.

If the incorrect arity happens to be defined, this can lead to bizarre errors originating far from the transit code or top-level constructor; if not defined, it results in "Error: Invalid arity: X".

I discovered this by using partial to define a read handler, which of course constructs a function with many arities. The extra argument being passed to the function appears to be a Transit$TaggedValue, defined in transit-js.

Steps to Reproduce

Use a read-handler function with more than one arity. A complete minimal example, based on the official tutorial, can be found here:

https://gist.github.com/galdre/cc875e28590d253b2c40cdfd3f5ecd07