summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/bytecomp-tests.el
Commit message (Collapse)AuthorAgeFilesLines
* Prefer incf to cl-incf in testsStefan Kangas2025-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-reify-function): * test/lisp/emacs-lisp/cl-extra-tests.el (cl-getf): * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-for-as-arith-order-side-effects) (cl-macs-loop-for-as-equals-then, cl-macs-loop-do, cl-macs-loop-finally) (cl-macs-loop-in-ref, cl-macs-loop-being-elements-of-ref) (cl-macs-test--symbol-macrolet, cl-the): * test/lisp/emacs-lisp/cl-seq-tests.el (cl-lib-test-remove) (cl-lib-test-remove-if-not): * test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el (edebug-test-code-range): * test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-deduplicate): * test/lisp/emacs-lisp/generator-tests.el (cps-while-incf): (cps-test-iter-cleanup-once-only): * test/lisp/emacs-lisp/hierarchy-tests.el (hierarchy-labelfn-button-if-does-not-button-unless-condition) (hierarchy-labelfn-button-if-does-button-when-condition): * test/lisp/emacs-lisp/let-alist-tests.el (let-alist-evaluate-once): * test/lisp/emacs-lisp/lisp-mode-tests.el (indent-sexp, lisp-indent-region): * test/lisp/emacs-lisp/map-tests.el (test-map-elt-gv) (test-setf-map-with-function): * test/lisp/emacs-lisp/multisession-tests.el (multi-test-sqlite-simple) (multi-test-sqlite-busy, multi-test-files-simple) (multi-test-files-busy): * test/lisp/emacs-lisp/oclosure-tests.el (oclosure-test, oclosure-test-mutate): * test/lisp/emacs-lisp/track-changes-tests.el (track-changes-tests--random): * test/lisp/files-tests.el (files-tests--with-buffer-offer-save): * test/lisp/net/shr-tests.el (shr-test/zoom-image): * test/lisp/replace-tests.el (replace-tests-with-undo): * test/src/buffer-tests.el (test-overlay-randomly): * test/src/data-tests.el (test-bool-vector-bv-from-hex-string): * test/src/fns-tests.el (fns-tests-sort): * test/src/json-tests.el (json-insert/signal, json-insert/throw): * test/src/minibuf-tests.el (minibuf-tests--strings-to-symbol-alist) (minibuf-tests--strings-to-string-alist) (minibuf-tests--strings-to-string-hashtable) (minibuf-tests--strings-to-symbol-hashtable): * test/src/process-tests.el (make-process/file-handler/found): Prefer incf to cl-incf.
* Prefer plusp/minusp to cl-plusp/cl-minuspStefan Kangas2025-02-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/dired.el (dired--move-to-next-line): * lisp/emacs-lisp/ert.el (ert-run-tests-batch, ert-face-for-stats): * lisp/emacs-lisp/pp.el (pp--format-definition): * lisp/gnus/gnus-icalendar.el (gnus-icalendar-event--org-timestamp): * lisp/ibuffer.el (ibuffer-compile-format, ibuffer--format-title) (ibuffer--format-summary): * lisp/image-mode.el (image-transform-set-percent): * lisp/international/emoji.el (emoji--list-generate, emoji--read-emoji): * lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation) (ebrowse-set-member-buffer-column-width) (ebrowse-cyclic-display-next/previous-member-list) (ebrowse-draw-member-short-fn) (ebrowse-switch-member-buffer-to-sibling-class, ebrowse-push-position): * lisp/textmodes/dns-mode.el (dns-mode-reverse-and-expand-ipv6): * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--not-writable-directory) (bytecomp-tests--dest-mountpoint) (bytecomp-tests--target-file-no-directory): * test/lisp/emacs-lisp/cl-seq-tests.el (cl-member-if-test) (cl-member-if-not-test, cl-assoc-if-not-test, cl-rassoc-if-test) (cl-rassoc-if-not-test): * test/src/emacs-module-tests.el (mod-test-add-nanosecond/valid): Prefer plusp and minusp to cl-plusp and cl-minusp.
* Port dest-mountpoint test to suspicious bwrapPaul Eggert2025-01-311-0/+6
| | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el: (bytecomp-tests--dest-mountpoint): Skip test if bwrap prohibits even ‘true’, which it does on my Ubuntu 24.10 platform.
* Update copyright year to 2025Paul Eggert2025-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* ; Fix thinko in my last changeStefan Kangas2024-10-021-0/+3
| | | | | | * lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare): Fix thinko. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defcustom-local): Update test.
* Warn about bad defcustom :local keyword at compile timeStefan Kangas2024-10-021-0/+8
| | | | | | | * lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare): Warn about invalid values for the defcustom :local keyword. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defcustom-local): New test.
* ; Reword :reverse-video warningMattias Engdegård2024-09-291-1/+1
| | | | | | * lisp/emacs-lisp/bytecomp.el (bytecomp--check-cus-face-spec): * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defface-spec): Clarify. (See bug#73552.)
* Warn about :reverse-video in deffaceMattias Engdegård2024-09-291-0/+4
| | | | | | | | | | | This attribute keyword has been non-working in defface for 14 years, thus warning about it is both safe and decent. * lisp/emacs-lisp/bytecomp.el (bytecomp--check-cus-face-spec): Warn and suggest :inverse-video to be used instead. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defface-spec): Add a test case. * etc/NEWS: Notify the user.
* Warn about bad face specs in `defface` at compile timeMattias Engdegård2024-09-271-0/+26
| | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile--custom-declare-face): Byte-compile `defface` forms, or the byte-compile handler won't be called. (bytecomp--check-cus-face-spec): New. (bytecomp--custom-declare): Call it. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defface-spec): New tests.
* Better format string compilation warningMattias Engdegård2024-04-221-1/+1
| | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-format-warn): Speed up by eliminating the temporary buffer. Detect invalid format sequences. Use plurals properly. * test/lisp/emacs-lisp/bytecomp-tests.el: Update test.
* Make lexical-binding cookie warning test more robustMattias Engdegård2024-04-031-6/+8
| | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--lexical-binding-cookie): Run with lexical-binding both on and off.
* Repair miscompilation of single-arg `apply` (bug#69533)Mattias Engdegård2024-03-041-0/+3
| | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-apply): Don't optimise single-argument `apply`; it's a legacy construct. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case.
* Grudgingly accept function values in the function positionMattias Engdegård2024-02-051-0/+16
| | | | | | | | * lisp/emacs-lisp/cconv.el (cconv-convert): Warn about (F ...) where F is a non-symbol function value (bytecode object etc), but let it pass for compatibility's sake (bug#68931). * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp--fun-value-as-head): New test.
* Use handler-bind to repair bytecomp-testsMattias Engdegård2024-01-041-12/+6
| | | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--error-frame, bytecomp--byte-op-error-backtrace): Make test pass again and simplify, using handler-bind instead of the previous debugger hack.
* Merge from savannah/emacs-29Po Lu2024-01-021-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dc4e6b13296 ; Update copyright years in more files 64b37776318 ; Run set-copyright from admin.el 8e1c56ae467 ; Add 2024 to copyright years # Conflicts: # doc/misc/modus-themes.org # doc/misc/texinfo.tex # etc/NEWS # etc/refcards/ru-refcard.tex # etc/themes/modus-operandi-theme.el # etc/themes/modus-themes.el # etc/themes/modus-vivendi-theme.el # lib/alloca.in.h # lib/binary-io.h # lib/c-ctype.h # lib/c-strcasecmp.c # lib/c-strncasecmp.c # lib/careadlinkat.c # lib/cloexec.c # lib/close-stream.c # lib/diffseq.h # lib/dup2.c # lib/filemode.h # lib/fpending.c # lib/fpending.h # lib/fsusage.c # lib/getgroups.c # lib/getloadavg.c # lib/gettext.h # lib/gettime.c # lib/gettimeofday.c # lib/group-member.c # lib/malloc.c # lib/md5-stream.c # lib/md5.c # lib/md5.h # lib/memmem.c # lib/memrchr.c # lib/nanosleep.c # lib/save-cwd.h # lib/sha1.c # lib/sig2str.c # lib/stdlib.in.h # lib/strtoimax.c # lib/strtol.c # lib/strtoll.c # lib/time_r.c # lib/xalloc-oversized.h # lisp/auth-source-pass.el # lisp/emacs-lisp/lisp-mnt.el # lisp/emacs-lisp/timer.el # lisp/info-look.el # lisp/jit-lock.el # lisp/loadhist.el # lisp/mail/rmail.el # lisp/net/ntlm.el # lisp/net/webjump.el # lisp/progmodes/asm-mode.el # lisp/progmodes/project.el # lisp/progmodes/sh-script.el # lisp/textmodes/flyspell.el # lisp/textmodes/reftex-toc.el # lisp/textmodes/reftex.el # lisp/textmodes/tex-mode.el # lisp/url/url-gw.el # m4/alloca.m4 # m4/clock_time.m4 # m4/d-type.m4 # m4/dirent_h.m4 # m4/dup2.m4 # m4/euidaccess.m4 # m4/fchmodat.m4 # m4/filemode.m4 # m4/fsusage.m4 # m4/getgroups.m4 # m4/getloadavg.m4 # m4/getrandom.m4 # m4/gettime.m4 # m4/gettimeofday.m4 # m4/gnulib-common.m4 # m4/group-member.m4 # m4/inttypes.m4 # m4/malloc.m4 # m4/manywarnings.m4 # m4/mempcpy.m4 # m4/memrchr.m4 # m4/mkostemp.m4 # m4/mktime.m4 # m4/nproc.m4 # m4/nstrftime.m4 # m4/pathmax.m4 # m4/pipe2.m4 # m4/pselect.m4 # m4/pthread_sigmask.m4 # m4/readlink.m4 # m4/realloc.m4 # m4/sig2str.m4 # m4/ssize_t.m4 # m4/stat-time.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/stdio_h.m4 # m4/stdlib_h.m4 # m4/stpcpy.m4 # m4/strnlen.m4 # m4/strtoimax.m4 # m4/strtoll.m4 # m4/time_h.m4 # m4/timegm.m4 # m4/timer_time.m4 # m4/timespec.m4 # m4/unistd_h.m4 # m4/warnings.m4 # nt/configure.bat # nt/preprep.c # test/lisp/register-tests.el
| * ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
| |
* | ; Fix typosStefan Kangas2023-12-101-4/+4
| |
* | Fix variable aliasing bytecode miscompilation (bug#67116)Mattias Engdegård2023-11-131-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The compiler didn't cancel aliasing if the aliased variable was modified in a variable binding in the same `let` that created the alias. For example, (let ((x A)) (let ((y x) (z (setq x B))) y)) would incorrectly substitute y->x in the body form despite x being already modified at that point, which normally should have cancelled the aliasing. Bug reported by Alan Mackenzie. * lisp/emacs-lisp/byte-opt.el (byte-optimize--aliased-vars): Now an alist that also contains the aliases; update the doc string. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): * lisp/emacs-lisp/byte-opt.el (byte-optimize-let-form): Detect aliasing early for `let`-bound variables as well. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test cases.
* | Fix bytecomp-tests--dest-mountpoint test failureMattias Engdegård2023-11-041-1/+2
| | | | | | | | | | | | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--dest-mountpoint): Add lexical cookie. Bug reported and fix suggested by Jens Schmidt (https://lists.gnu.org/archive/html/emacs-devel/2023-10/msg00719.html)
* | Move lexical-binding warning from checkdoc to byte-compilerMattias Engdegård2023-10-211-4/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This warning is much more appropriate for the compiler, since lexical binding affects what it can reason and warn about, than for checkdoc as the warning has no bearing to documentation at all. The move also improves the reach of the warning. * etc/NEWS: Update. * lisp/emacs-lisp/checkdoc.el (checkdoc-lexical-binding-flag) (checkdoc-file-comments-engine): Move warning from here.... * lisp/emacs-lisp/bytecomp.el (byte-compile-file): ...to here. * test/lisp/emacs-lisp/bytecomp-resources/no-byte-compile.el: * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--unescaped-char-literals) (bytecomp-tests-function-put, bytecomp-tests--not-writable-directory) (bytecomp-tests--target-file-no-directory): Update tests. (bytecomp-tests--log-from-compilation) (bytecomp-tests--lexical-binding-cookie): New test.
* | Warn about duplicated :tag strings in defcustom choicesMattias Engdegård2023-09-191-1/+4
| | | | | | | | | | | | | | | | It is bad user experience when two menu items have identical labels. * lisp/emacs-lisp/bytecomp.el (bytecomp--check-cus-type): Add check. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defcustom-type): Add test case.
* | Expanded defcustom type byte-compilation warnings (bug#65852)Mattias Engdegård2023-09-171-7/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Warn about more kinds of mistakes in :type arguments of `defcustom` and `define-widget`. These include: - misplaced keyword args, as in (const red :tag "A reddish hue") - missing subordinate types, as in (repeat :tag "List of names") or (choice list string) - duplicated values, as in (choice (const yes) (const yes)) - misplaced `other` member, as in (choice (const red) (other nil) (const blue)) - various type name mistakes, as in (vector bool functionp) * lisp/emacs-lisp/bytecomp.el (byte-compile--defcustom-type-quoted) (byte-compile-nogroup-warn): Remove. (byte-compile-normal-call): Remove call to the above. (bytecomp--cus-warn, bytecomp--check-cus-type) (bytecomp--custom-declare): New.
* | Shorten docstrings generated by cl-defstructDamien Cassou2023-09-131-0/+17
| | | | | | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Split the first line of generated docstrings if either the struct name or a field name is very long. This reduces the likelihood of "docstring wider than 80 characters" errors. (Bug#65790)
* | Shorten docstrings generated by cl-defsubstDamien Cassou2023-09-131-0/+11
| | | | | | | | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-defsubst): Split the first line of the docstring into 2 lines if the function name is very long. Additionally, remove the word "inlining" in the generated docstring as it is not very useful and increases the likelihood of "docstring wider than 80 characters" errors. (Bug#65790)
* | bytecomp-tests.el: Add new helper functionDamien Cassou2023-09-131-2/+5
| | | | | | | | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp--without-warning-test): Add helper function. (bytecomp-warn--ignore): Use the helper.
* | Add byte-compiler warning about useless trailing cond clausesMattias Engdegård2023-09-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Warn about clauses after the default clause, as in (cond ((= x 0) (say "none")) (t (say "some")) (say "goodbye")) because they are very much an indicator of a mistake (such as misplaced brackets), and since they are deleted by the optimiser, any other warnings there are lost and the user wouldn't know that something is wrong otherwise. * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Add warning. * etc/NEWS: Announce. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Add test case.
* | Don't cache warnings between bytecode compilation testsMattias Engdegård2023-09-091-6/+11
| | | | | | | | | | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--with-fresh-warnings): New macro. (test-byte-comp-compile-and-load, bytecomp--with-warning-test): Use it.
* | Check keyword args of make-processHelmut Eller2023-08-081-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The functions make-process and make-network-process have many keyword args and it's easy to misspell some of them. Use a compiler macro to warn about some possible mistakes. * lisp/emacs-lisp/bytecomp.el (bytecomp--check-keyword-args): New helper. (make-process, make-network-process): Define a compiler macro that performs some checks but doesn't anything else. * test/lisp/emacs-lisp/bytecomp-tests.el: Add some tests. * test/lisp/emacs-lisp/bytecomp-resources/: (warn-make-process-missing-keyword-arg.el, warn-make-process-missing-keyword-value.el, warn-make-process-repeated-keyword-arg.el, warn-make-process-unknown-keyword-arg.el): New test files
* | ; Fix bad bytecomp-tests casesMattias Engdegård2023-08-081-8/+10
| | | | | | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Repair broken test cases.
* | Teach byte-compiler about Aristotelian identityMattias Engdegård2023-08-081-0/+3
| | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-equal, byte-optimize-eq): Optimise (eq X X) -> t where X is a variable; idem for eql and equal. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case.
* | Don't allow the `eq` and `unbind` byte-ops to commute (bug#65017)Mattias Engdegård2023-08-041-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-after-unwind-ops): Cease sinking `eq` past `unwind`, because that optimised away the let-binding in (let ((symbols-with-pos-enabled nil)) (eq x y)) and `eq` is currently sensitive to `symbols-with-pos-enabled`. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp--eq-symbols-with-pos-enabled): New test.
* | Fix broken byte-compilation of unary comparisonsMattias Engdegård2023-07-261-0/+5
| | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-opt--nary-comparison): Fix a typo causing miscompilation of code such as (OP X), where OP is <, >, <=, >= or =. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case. Reported by Richard Copley.
* | Provide backtrace for byte-ops aref and asetMattias Engdegård2023-07-261-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Produce synthetic backtrace entries for `aref` and `aset` byte-ops when the index is non-fixnum, or is out of range for vector or record arguments (bug#64613). * src/bytecode.c (exec_byte_code): Detect type and range errors in-line for aref and aset. * src/data.c (syms_of_data): Declare symbols Qaref and Qaset. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--byte-op-error-cases): Add test cases.
* | ; bytecode backtrace test clean-upMattias Engdegård2023-07-261-11/+11
| |
* | Provide backtrace for byte-ops car, cdr, setcar, setcdr, nth and eltMattias Engdegård2023-07-141-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Include calls to these primitives from byte-compiled code in backtraces. For nth and elt, not all errors are covered. (Bug#64613) * src/bytecode.c (exec_byte_code): Add error backtrace records for car, cdr, setcar, setcdr, nth and elt. * src/data.c (syms_of_data): Add missing defsyms for car, setcar, setcdr, nth and elt. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--error-frame, bytecomp-tests--byte-op-error-cases) (bytecomp--byte-op-error-backtrace): New test.
* | Don't compile (+ X 0) as (* X 1)Mattias Engdegård2023-06-211-0/+4
| | | | | | | | | | | | | | | | | | | | Previously (+ X 0) was reduced to (+ X) which became (* X 1) in codegen, but this is wrong for X = -0.0 and also slightly slower. * lisp/emacs-lisp/byte-opt.el (byte-optimize-plus): Don't reduce an addition to (+ X) by eliminating zeros; retain one 0 argument. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case.
* | Clean up defcustom type quote checkMattias Engdegård2023-05-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile--suspicious-defcustom-choice): Rename to... (byte-compile--defcustom-type-quoted): ...this and rewrite to make more sense. All callers updated. (byte-compile-nogroup-warn): Better warning message. * test/lisp/emacs-lisp/bytecomp-tests.el (test-bytecomp-defgroup-choice): This never failed because it wasn't actually a test. Turn it into... (bytecomp-test-defcustom-type-quoted): ...this, which is.
* | Use `mutate-constant` as warning identifierMattias Engdegård2023-05-131-5/+5
| | | | | | | | | | | | | | | | | | | | | | * etc/NEWS: * lisp/emacs-lisp/byte-run.el (with-suppressed-warnings): * lisp/emacs-lisp/bytecomp.el (byte-compile-warnings) (byte-compile-form): * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Use the new warning name `mutate-constant` instead of using the somewhat overloaded `suspicious`.
* | Byte-compiler warning about mutation of constant valuesMattias Engdegård2023-05-131-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we can easily detect mutation of constants (quoted lists, strings and vectors), warn. For example, (setcdr '(1 . 2) 3) (nreverse [1 2 3]) (put-text-property 0 3 'face 'highlight "moo") Such code can result in surprising behaviour and problems that are difficult to debug. * lisp/emacs-lisp/bytecomp.el (byte-compile-form, mutating-fns): Add the warning and a list of functions to warn about. * etc/NEWS: Announce. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Add test cases.
* | Don't rewrite (nconc X nil) -> X for any X (bug#63103)Mattias Engdegård2023-04-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the last cdr of a non-terminal argument to `nconc` is overwritten no matter its value: (nconc (cons 1 2) nil) => (1) a terminating nil arg cannot just be eliminated unconditionally. * lisp/emacs-lisp/byte-opt.el (byte-optimize-nconc): Only eliminate a terminal nil arg to `nconc` if preceded by a nonempty proper list. Right now we only bother to prove this for `(list ...)`, so that (nconc (list 1 2 3) nil) -> (list 1 2 3) * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test cases.
* | Consolidate existing warnings about unused return valuesMattias Engdegård2023-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the warning about unused return values from calls to side-effect-free functions from the source-level optimiser to the code generator, where it can be unified with the special-purpose warning about unused values from `mapcar`. This change also cures spurious duplicate warnings about the same code, makes the warnings amenable to suppression through `with-suppressed-warnings`, and now warns about some unused values that weren't caught before. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Move warning away from here. * lisp/emacs-lisp/byte-run.el (with-suppressed-warnings): * lisp/emacs-lisp/bytecomp.el (byte-compile-warnings): Doc string updates. (byte-compile-form): Put the new warnings here. (byte-compile-normal-call): Move mapcar warning away from here. * lisp/emacs-lisp/bytecomp.el (byte-compile-ignore): Compile args to `ignore` for value to avoid unused-value warnings, and then discard the generated values immediately thereafter. Mostly this does not affect the generated code but in rare cases it might result in slightly worse code. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Adapt test.
* | Warn about unwind-protect without unwind formsMattias Engdegård2023-03-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `unwind-protect` without unwind forms is not just pointless but often indicates a mistake where the intended unwind part is misplaced, as in (unwind-protect (progn PROT-FORMS UNWIND-FORMS)) ; oops or (unwind-protect PROT-FORM) UNWIND-FORMS ; also oops or entirely forgotten for that matter. Warning about this makes sense, and the warning can always be silenced by removing the `unwind-protect` altogether if it shouldn't be there in the first place. * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Implement warning. * etc/NEWS: Announce. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Add test case.
* | Repair and speed up safe-copy-tree and make it internal (bug#61962)Mattias Engdegård2023-03-121-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no particular requirement for safe-copy-tree so let's make it internal for now. The new implementation is faster and more correct. * doc/lispref/lists.texi (Building Lists): * etc/NEWS: Remove doc and announcement. * lisp/subr.el (safe-copy-tree--seen, safe-copy-tree--1) (safe-copy-tree): Remove old version. * lisp/emacs-lisp/bytecomp.el (bytecomp--copy-tree-seen) (bytecomp--copy-tree-1, bytecomp--copy-tree): Add new version. (byte-compile-initial-macro-environment): Use it. * test/lisp/subr-tests.el (subr--safe-copy-tree): * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp--copy-tree): Move and improve tests.
* | Fix `cond` miscompilation bugMattias Engdegård2023-03-021-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug that miscompiled (cond ... C S1...Sn) where S1...Sn are switch clauses (that can be compiled into a switch op) and C a non-switch clause, by tucking on an extra copy of C at the end. This was a serious wrong-code bug when the condition of C had side-effects; otherwise it was only a waste of time and space. * lisp/emacs-lisp/bytecomp.el (byte-compile-cond): Fix. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case.
* | Warn about `condition-case` without handlersMattias Engdegård2023-02-271-0/+6
| | | | | | | | | | | | | | | | | | | | Omitting handlers from a `condition-case` form makes it useless since no errors are caught. * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): New warning. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test--with-suppressed-warnings): Add test case. * etc/NEWS: Announce.
* | (bytecomp-warn--ignore): New testStefan Monnier2023-02-251-2/+10
| | | | | | | | | | | | | | Add tests for the interaction of `ignore` with warnings. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-warn--ignore): New test. (bytecomp--with-warning-test): Really make it a function.
* | bytecomp--with-warning-test: Make it a functionStefan Monnier2023-02-251-6/+7
| | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (bytecomp--with-warning-test): Make it a function.
* | Fix test errors when run with fancy charset (bug#61534)Mattias Engdegård2023-02-161-1/+3
| | | | | | | | | | | | | | | | | | | | * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--unescaped-char-literals, test-suppression): Bind `text-quoting-style` to `grave` around tests to force generation of ASCII quotes. * test/src/lread-tests.el (lread-tests--unescaped-char-literals): Subject the reference string to the same text styling as that under scrutiny.
* | Merge from origin/emacs-29Eli Zaretskii2023-01-011-1/+1
|\| | | | | | | | | | | | | | | | | | | | | cae528457c ; Add 2023 to copyright years. b394359261 Improve documentation of 'isearch-open-overlay-temporary' ab3210e709 Document 'use-package' in the 2 main manuals # Conflicts: # etc/refcards/ru-refcard.tex # lib/explicit_bzero.c # m4/explicit_bzero.m4
| * ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
| |