1

The following code evaluates successfully using eval-defun and runs as I would expect:

(require 'cl-lib)
(defun my/sample-function ()
  (let ((my-ht (make-hash-table)))
    (puthash :a 1 my-ht)
    (puthash :b 2 my-ht)
    (cl-loop for key being the hash-keys of my-ht using (hash-values value)
             do
             (prin1 (cons key value)))))

with

(my/sample-function)
=> (:a . 1)(:b . 2)nil

However, edebug-defun complains:

Debugger entered--Lisp error: (error "Bad ‘using’ clause")                 
  signal(error ("Bad ‘using’ clause"))                                     
  error("Bad `using' clause")                                              
  cl--parse-loop-clause()                                                  
  #[128 "\306\307\310\311\312\311\306\313!\"\"\">\204\314\312\315\3...
  macroexpand((cl-loop for key being the hash-keys of my-ht using (edebug-a...
  macroexp-macroexpand((cl-loop for key being the hash-keys of my-ht using ...
  macroexp--expand-all((cl-loop for key being the hash-keys of my-ht using ...
  ...

I imagine that edebug is choking during instrumentation on the hash-table -specific parts of the complex cl-loop macro. This is the first time I've encountered this sort of problem with edebug.

I'm not certain that this is not the result of user-error though. In Common Lisp documentation the keywords appear singular with a different verb ordering (example source):

(loop for k being the hash-key using (hash-value v) of h do ...

However, the structure used within my/sample-function above is the only form I have found to eval successfully.

I couldn't find anything relevant in debbugs.

emacs -Q version 25.1.1

  • #24750 I think – npostavs Mar 25 '17 at 18:00
  • @npostavs I agree. I can confirm that my problem is fixed in 26. Add as an answer and I'll close this Q; thx – ebpa Mar 25 '17 at 18:47
2

This is Emacs Bug#24750, which is fixed in the master branch (what will become 26.1). For earlier versions, you can add ["using" (symbolp symbolp)] to cl-loop's edebug spec.

(put 'cl-loop 'edebug-form-spec
     '(&rest &or
             [[&or "for" "as" "with" "and"]
              sexp]
             [[&or "from" "upfrom" "downfrom" "to" "upto" "downto" "above" "below" "by" "in" "on" "=" "across" "repeat" "while" "until" "always" "never" "thereis" "collect" "append" "nconc" "sum" "count" "maximize" "minimize" "if" "unless" "return"]
              form]
             ["using" (symbolp symbolp)]
             symbolp form))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.