convex
convex copied to clipboard
Should `MultiFn` allow dead code?
((fn ([a] :first) ([a] :second)) 42)
;; :first
Here we have two different bodies for the same arity and only the former is considered at call. Sounds like it could produces some nasty bugs, the kind of bugs that happen rarely but when they do, they can make you go crazy.
This looks trivial but is actually an undecidable problem given:
- Destructuring
- Future possible type constraints
- Future possibly arbitrary pre-condition code
Possible enhancement to to allow MultiFns to catch :ARGUMENT, :TYPE and :ARITY errors and proceed to try the next body in such cases.
Workaround at the user level is to provide a customer expander / compiler that detects such cases according to the user's preferred logic.
I think this is a wontfix directly, but could be addressed in future static analysis tools / off-chain compilers. If we implement on-chain, it would be V2