Hello, Consider the following code
(gen-interface :name IntStack :methods [[stackPeek [] int] [stackPush [int] void] [stackPop [] int] [stackDepth [] int]]) (deftype IntStackImpl [^{:tag ints :unsynchronized-mutable true} data ^{:tag int :unsynchronized-mutable true} depth] IntStack (stackPeek [this] (aget data depth)) (stackPush [this value] (when (>= (inc depth) (alength data)) (let [data-length (alength data) new-data (int-array (* data-length 2))] (System/arraycopy data 0 new-data 0 data-length) (set! data new-data))) (set! depth (inc depth)) (aset data depth value)) (stackPop [this] (if (> depth 0) (let [value (aget data depth)] (set! depth (dec depth)) value) (throw (IllegalStateException. "Stack is already empty!")))) (stackDepth [this] depth)) This is very simple stack implementation over plain java array. It does not compile with the following message: CompilerException java.lang.VerifyError: (class: clojure/data/xml/IntStackImpl, method: stackPop signature: ()I) Expecting to find integer on stack However, when I replace the body of stackPop with, say, plain zero literal 0, the method seems to pass the compilation, because then I'm getting similar error on stackPush method instead. Placing type hints inside stackPop method does not work (in fact, it is even an error to place them, say, on value local binding). What am I doing wrong here? How to make the class compile? Cheers, Vladimir. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en