Hey all :)
Have hit what I think is a compiler bug this morning, wondering whether it's one I should submit to JIRA?
Here's what I believe to be a minimal repro:
(defprotocol P
(^double p1 [p a])
(^double p2 [p a]))
(let [p (reify P)]
(min 0.0
(case :p1
:p1 (p1 p :foo)
:p2 (p2 p :foo))))
Error:
1. Caused by java.lang.ArrayIndexOutOfBoundsException
Index -1 out of bounds for length 0
Frame.java: 1262 clojure.asm.Frame/merge
Frame.java: 1238 clojure.asm.Frame/merge
MethodWriter.java: 1604 clojure.asm.MethodWriter/computeAllFrames
MethodWriter.java: 1540 clojure.asm.MethodWriter/visitMaxs
... (have a fuller trace I can send, or the above code snippet should work at a REPL)
Any of the following make this error go away
- removing the type hinting
- adding a nil default to the case
- making the protocol functions normal type-hinted
defn
s
- raising the
case
out of the min
(removing the min
)
I've managed to refactor the original code to work around the issue, but please do let me know if I should raise a JIRA ticket.
Cheers,
James