unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#31715: cl-incf and cl-decf error out when passed a nil-valued variable as 'offset'
@ 2018-06-04 20:06 Clément Pit-Claudel
  2018-06-04 22:58 ` Noam Postavsky
  0 siblings, 1 reply; 14+ messages in thread
From: Clément Pit-Claudel @ 2018-06-04 20:06 UTC (permalink / raw)
  To: 31715


[-- Attachment #1.1: Type: text/plain, Size: 769 bytes --]

Hi all,

The following works:
  (let ((x 1)) (cl-incf x nil))

… but following raises "setq: Wrong type argument: number-or-marker-p, nil":
  (let ((x 1) (y nil)) (cl-incf x y))

… yet the docs say this, which suggests that both should work:
  (cl-incf PLACE &optional X)
  Increment PLACE by X (1 by default).

The issue comes from the expansion of cl-incf:

    (defmacro cl-incf (place &optional x) …
      (if (symbolp place)
          (list 'setq place (if x (list '+ place x) (list '1+ place)))
        (list 'cl-callf '+ place (or x 1))))

Shouldn't that `if x' check be quoted?  Same for the second branch of the if (shouldn't the `(or x 1)' part be quoted, too?)

cl-decf has the same issue.  Am I missing something?

Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-04-21 13:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-04 20:06 bug#31715: cl-incf and cl-decf error out when passed a nil-valued variable as 'offset' Clément Pit-Claudel
2018-06-04 22:58 ` Noam Postavsky
2018-06-04 23:43   ` Michael Heerdegen
2018-06-05  0:12     ` Noam Postavsky
2018-06-05  0:40       ` Michael Heerdegen
2022-04-21 13:11         ` Lars Ingebrigtsen
2018-06-05 15:19       ` Clément Pit-Claudel
2018-06-05 22:53         ` Noam Postavsky
2018-06-05 23:01           ` Clément Pit-Claudel
2018-06-05 23:26             ` Noam Postavsky
2018-06-05 23:36               ` Clément Pit-Claudel
2018-06-06  0:32               ` Michael Heerdegen
2018-06-06  0:37                 ` Noam Postavsky
2018-06-05 15:03   ` Clément Pit-Claudel

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).