<div>The following works as expected when evaluated, but throws an error when compiling.</div><div><br></div><div>(defun hashmap-to-hashtable (hashmap &key (keyfun #'identity) (valfun #'identity) (invert? nil)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> &allow-other-keys &rest rest)</div><div> (let ((keyset (#"keySet" hashmap))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(table (apply 'make-hash-table (remf :invert? (remf :valfun (remf :keyfun rest))))))</div>
<div> (with-constant-signature ((iterator "iterator" t) (hasnext "hasNext") (next "next"))</div><div> (loop with iterator = (iterator keyset)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> while (hasNext iterator)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> for item = (next iterator)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> do (if invert?</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(setf (gethash (funcall valfun (#"get" hashmap item)) table) (funcall keyfun item))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>(setf (gethash (funcall keyfun item) table) (funcall valfun (#"get" hashmap item)))))</div><div> table)))</div><div><br></div><div>-> Error</div>
<div><br></div><div><div>&REST/&BODY must be followed by a variable.</div><div> [Condition of type PROGRAM-ERROR]</div><div><br></div><div>Restarts:</div><div> 0: [ABORT] Abort compilation.</div><div> 1: [ABORT] Return to SLIME's top level.</div>
<div> 2: [ABORT] Abort thread.</div><div><br></div><div>Backtrace:</div><div> 0: (SYSTEM:MAKE-CLOSURE (LAMBDA (#:G29656 &KEY (# NIL #:G29659) (# NIL #:G29661) (# NIL) &ALLOW-OTHER-KEYS ...) NIL) NIL)</div><div> 1: (JVM::P1-COMPILAND #S(JVM::COMPILAND :NAME HASHMAP-TO-HASHTABLE :LAMBDA-EXPRESSION (LAMBDA (#1=#:G29656 &KEY ((:KEYFUN #:G29658) NIL #:G29659) ((:VALFUN #:G29660) NIL #:G29661) ((:INVERT? #2=#:G29662)..</div>
<div> 2: (JVM::P1-FUNCTION #'(SYSTEM:NAMED-LAMBDA HASHMAP-TO-HASHTABLE (HASHMAP &KEY (KEYFUN #'IDENTITY) (VALFUN #'IDENTITY) (INVERT? NIL) &ALLOW-OTHER-KEYS ...) (BLOCK HASHMAP-TO-HASHTABLE (LET # #))))</div>
<div> 3: (JVM::P1 #'(SYSTEM:NAMED-LAMBDA HASHMAP-TO-HASHTABLE (HASHMAP &KEY (KEYFUN #'IDENTITY) (VALFUN #'IDENTITY) (INVERT? NIL) &ALLOW-OTHER-KEYS ...) (BLOCK HASHMAP-TO-HASHTABLE (LET # #))))</div>
<div>
Locals:</div><div> "??" = "??"</div><div> 4: (JVM::P1 (SYSTEM:NAMED-LAMBDA HASHMAP-TO-HASHTABLE (HASHMAP &KEY (KEYFUN #'IDENTITY) (VALFUN #'IDENTITY) (INVERT? NIL) &ALLOW-OTHER-KEYS ...) (BLOCK HASHMAP-TO-HASHTABLE (LET # #))))</div>
<div> 5: (JVM::P1-LET*-VARS #S(JVM::LET/LET*-NODE :FORM NIL :COMPILAND #S(JVM::COMPILAND :NAME NIL :LAMBDA-EXPRESSION (LAMBDA NIL (SYSTEM:%DEFUN 'HASHMAP-TO-HASHTABLE (SYSTEM:NAMED-LAMBDA HASHMAP-TO-HASHTABLE ..</div>
<div> 6: (JVM::P1-LET/LET* (LET* ((#:G29655 #)) (SYSTEM:%DEFUN 'HASHMAP-TO-HASHTABLE #:G29655)))</div><div> 7: (JVM::P1 (LET* ((#:G29655 #)) (SYSTEM:%DEFUN 'HASHMAP-TO-HASHTABLE #:G29655)))</div><div> 8: (JVM::P1-FUNCTION-CALL (SYSTEM:%DEFUN 'HASHMAP-TO-HASHTABLE (SYSTEM:NAMED-LAMBDA HASHMAP-TO-HASHTABLE (HASHMAP &KEY # # # &ALLOW-OTHER-KEYS ...) (BLOCK HASHMAP-TO-HASHTABLE #))))</div>
<div> 9: (JVM::P1-BODY ((SYSTEM:%DEFUN 'HASHMAP-TO-HASHTABLE (SYSTEM:NAMED-LAMBDA HASHMAP-TO-HASHTABLE # #))))</div><div> 10: (#<FUNCTION {79F502}>)</div><div> 11: (#<FUNCTION {C49395}>)</div><div> 12: (#<FUNCTION {E4ED69}> NIL (LAMBDA NIL (DEFUN HASHMAP-TO-HASHTABLE (HASHMAP &KEY # # # &ALLOW-OTHER-KEYS ...) (LET # #))))</div>
<div> 13: (#<FUNCTION (LAMBDA ()) {B5506C}>)</div><div> 14: (JRUN-EXCEPTION-PROTECTED #<FUNCTION (LAMBDA ()) {B5506C}>)</div><div> 15: ((FLET SWANK-BACKEND:SWANK-COMPILE-STRING) "(defun hashmap-to-hashtable (hashmap &key (keyfun #'identity) (valfun #'identity) (invert? nil)</div>
<div> <span class="Apple-tab-span" style="white-space:pre"> </span> &allow-other-keys &rest rest)</div><div> (let ((keyset (#\"..</div><div><br></div></div>