Welcome! Please see the About page for a little more info on how this works.

0 votes
in tools.emitter.jvm by

user> (loop [acc 0
             col (range 50)]
        (if-not (empty? col)
          (recur (+ acc (first col)) (rest col))
          acc))


Generates exception


expected: (= (apply + (range 50)) (e/eval (quote (loop [acc 0 col (range 50)] (if-not (empty? col) (recur (+ acc (first col)) (rest col)) acc)))))
  actual: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    clojure/tools/emitter/passes/jvm/annotate_internal_name$fn__8917.invoke()Ljava/lang/Object; @4: invokestatic
  Reason:
    Type 'java/lang/Number' (current frame, stack[0]) is not assignable to long_2nd
  Current Frame:
    bci: @4
    flags: { }
    locals: { 'clojure/tools/emitter/passes/jvm/annotate_internal_name$fn__8917' }
    stack: { 'java/lang/Number' }
  Bytecode:
    0x0000000: 2ab6 0045 b800 49b0

 at java.lang.Class.getDeclaredConstructors0 (Class.java:-2)
    java.lang.Class.privateGetDeclaredConstructors (Class.java:2671)
    java.lang.Class.getConstructor0 (Class.java:3075)
    java.lang.Class.newInstance (Class.java:412)
    clojure.tools.emitter.jvm$eval.invoke (clojure/tools/emitter/jvm.clj:105)
    clojure.tools.emitter.jvm$eval.invoke (clojure/tools/emitter/jvm.clj:83)
    clojure.tools.emitter.jvm.core_test$fn__8193$fn__8328.invoke (core_test.clj:74)
    clojure.tools.emitter.jvm.core_test/fn (core_test.clj:73)

2 Answers

0 votes
by

Comment made by: bronsa

Looks like a problem with boxing, not sure when I'll have time to investigate/fix this

0 votes
by
Reference: https://clojure.atlassian.net/browse/TEMJVM-11 (reported by arrdem)
...