aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-07-15 07:54:24 +0800
committerPo Lu2023-07-15 07:54:24 +0800
commitb6be92ffb69107ee224bd2f883bc621845ce9a33 (patch)
tree06da7fe86b063f34490d32d4ffcfc6b39b414377
parent11c8a2fa87df2b6cc505e670a972552750eab71f (diff)
parentd86755820c21ae717adb13f4894a12b1332fb2a7 (diff)
downloademacs-b6be92ffb69107ee224bd2f883bc621845ce9a33.tar.gz
emacs-b6be92ffb69107ee224bd2f883bc621845ce9a33.zip
Merge remote-tracking branch 'origin/master' into feature/android
-rw-r--r--lisp/vc/ediff-wind.el3
-rw-r--r--src/bytecode.c42
-rw-r--r--src/data.c5
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el58
4 files changed, 102 insertions, 6 deletions
diff --git a/lisp/vc/ediff-wind.el b/lisp/vc/ediff-wind.el
index 3077c562d63..7d7f849b09c 100644
--- a/lisp/vc/ediff-wind.el
+++ b/lisp/vc/ediff-wind.el
@@ -883,6 +883,9 @@ Create a new splittable frame if none is found."
883 (not (ediff-frame-has-dedicated-windows (window-frame wind))) 883 (not (ediff-frame-has-dedicated-windows (window-frame wind)))
884 ))) 884 )))
885 885
886(defvar x-fast-protocol-requests)
887(declare-function x-change-window-property "xfns.c")
888
886(defun ediff-frame-make-utility (frame) 889(defun ediff-frame-make-utility (frame)
887 (let ((x-fast-protocol-requests t)) 890 (let ((x-fast-protocol-requests t))
888 (x-change-window-property 891 (x-change-window-property
diff --git a/src/bytecode.c b/src/bytecode.c
index 4207ff0b71f..2eb53b0428a 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -646,7 +646,10 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
646 if (CONSP (TOP)) 646 if (CONSP (TOP))
647 TOP = XCAR (TOP); 647 TOP = XCAR (TOP);
648 else if (!NILP (TOP)) 648 else if (!NILP (TOP))
649 wrong_type_argument (Qlistp, TOP); 649 {
650 record_in_backtrace (Qcar, &TOP, 1);
651 wrong_type_argument (Qlistp, TOP);
652 }
650 NEXT; 653 NEXT;
651 654
652 CASE (Beq): 655 CASE (Beq):
@@ -668,7 +671,10 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
668 if (CONSP (TOP)) 671 if (CONSP (TOP))
669 TOP = XCDR (TOP); 672 TOP = XCDR (TOP);
670 else if (!NILP (TOP)) 673 else if (!NILP (TOP))
671 wrong_type_argument (Qlistp, TOP); 674 {
675 record_in_backtrace (Qcdr, &TOP, 1);
676 wrong_type_argument (Qlistp, TOP);
677 }
672 NEXT; 678 NEXT;
673 } 679 }
674 680
@@ -1032,7 +1038,15 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
1032 { 1038 {
1033 for (EMACS_INT n = XFIXNUM (v1); 0 < n && CONSP (v2); n--) 1039 for (EMACS_INT n = XFIXNUM (v1); 0 < n && CONSP (v2); n--)
1034 v2 = XCDR (v2); 1040 v2 = XCDR (v2);
1035 TOP = CAR (v2); 1041 if (CONSP (v2))
1042 TOP = XCAR (v2);
1043 else if (NILP (v2))
1044 TOP = Qnil;
1045 else
1046 {
1047 record_in_backtrace (Qnth, &TOP, 2);
1048 wrong_type_argument (Qlistp, v2);
1049 }
1036 } 1050 }
1037 else 1051 else
1038 TOP = Fnth (v1, v2); 1052 TOP = Fnth (v1, v2);
@@ -1552,7 +1566,15 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
1552 /* Like the fast case for Bnth, but with args reversed. */ 1566 /* Like the fast case for Bnth, but with args reversed. */
1553 for (EMACS_INT n = XFIXNUM (v2); 0 < n && CONSP (v1); n--) 1567 for (EMACS_INT n = XFIXNUM (v2); 0 < n && CONSP (v1); n--)
1554 v1 = XCDR (v1); 1568 v1 = XCDR (v1);
1555 TOP = CAR (v1); 1569 if (CONSP (v1))
1570 TOP = XCAR (v1);
1571 else if (NILP (v1))
1572 TOP = Qnil;
1573 else
1574 {
1575 record_in_backtrace (Qelt, &TOP, 2);
1576 wrong_type_argument (Qlistp, v1);
1577 }
1556 } 1578 }
1557 else 1579 else
1558 TOP = Felt (v1, v2); 1580 TOP = Felt (v1, v2);
@@ -1581,7 +1603,11 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
1581 { 1603 {
1582 Lisp_Object newval = POP; 1604 Lisp_Object newval = POP;
1583 Lisp_Object cell = TOP; 1605 Lisp_Object cell = TOP;
1584 CHECK_CONS (cell); 1606 if (!CONSP (cell))
1607 {
1608 record_in_backtrace (Qsetcar, &TOP, 2);
1609 wrong_type_argument (Qconsp, cell);
1610 }
1585 CHECK_IMPURE (cell, XCONS (cell)); 1611 CHECK_IMPURE (cell, XCONS (cell));
1586 XSETCAR (cell, newval); 1612 XSETCAR (cell, newval);
1587 TOP = newval; 1613 TOP = newval;
@@ -1592,7 +1618,11 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
1592 { 1618 {
1593 Lisp_Object newval = POP; 1619 Lisp_Object newval = POP;
1594 Lisp_Object cell = TOP; 1620 Lisp_Object cell = TOP;
1595 CHECK_CONS (cell); 1621 if (!CONSP (cell))
1622 {
1623 record_in_backtrace (Qsetcdr, &TOP, 2);
1624 wrong_type_argument (Qconsp, cell);
1625 }
1596 CHECK_IMPURE (cell, XCONS (cell)); 1626 CHECK_IMPURE (cell, XCONS (cell));
1597 XSETCDR (cell, newval); 1627 XSETCDR (cell, newval);
1598 TOP = newval; 1628 TOP = newval;
diff --git a/src/data.c b/src/data.c
index 5a31462d8ca..108ed97d1f6 100644
--- a/src/data.c
+++ b/src/data.c
@@ -4110,7 +4110,12 @@ syms_of_data (void)
4110 DEFSYM (Qunevalled, "unevalled"); 4110 DEFSYM (Qunevalled, "unevalled");
4111 DEFSYM (Qmany, "many"); 4111 DEFSYM (Qmany, "many");
4112 4112
4113 DEFSYM (Qcar, "car");
4113 DEFSYM (Qcdr, "cdr"); 4114 DEFSYM (Qcdr, "cdr");
4115 DEFSYM (Qnth, "nth");
4116 DEFSYM (Qelt, "elt");
4117 DEFSYM (Qsetcar, "setcar");
4118 DEFSYM (Qsetcdr, "setcdr");
4114 4119
4115 error_tail = pure_cons (Qerror, Qnil); 4120 error_tail = pure_cons (Qerror, Qnil);
4116 4121
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index 278496f5259..9813e9459c8 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -1929,6 +1929,64 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode js-mode python-mode)) \
1929 "#4=(a #5=(#4# b . #6=(#5# c . #4#)) (#6# d))" 1929 "#4=(a #5=(#4# b . #6=(#5# c . #4#)) (#6# d))"
1930 ")")))))) 1930 ")"))))))
1931 1931
1932(require 'backtrace)
1933
1934(defun bytecomp-tests--error-frame (fun args)
1935 "Call FUN with ARGS. Return result or (ERROR . BACKTRACE-FRAME)."
1936 (let* ((debugger
1937 (lambda (&rest args)
1938 ;; Make sure Emacs doesn't think our debugger is buggy.
1939 (cl-incf num-nonmacro-input-events)
1940 (throw 'bytecomp-tests--backtrace
1941 (cons args (cadr (backtrace-get-frames debugger))))))
1942 (debug-on-error t)
1943 (backtrace-on-error-noninteractive nil)
1944 (debug-on-quit t)
1945 (debug-ignored-errors nil))
1946 (catch 'bytecomp-tests--backtrace
1947 (apply fun args))))
1948
1949(defconst bytecomp-tests--byte-op-error-cases
1950 '(((car a) (wrong-type-argument listp a))
1951 ((cdr 3) (wrong-type-argument listp 3))
1952 ((setcar 4 b) (wrong-type-argument consp 4))
1953 ((setcdr c 5) (wrong-type-argument consp c))
1954 ((nth 2 "abcd") (wrong-type-argument listp "abcd"))
1955 ((elt (x y . z) 2) (wrong-type-argument listp z))
1956 ;; Many more to add
1957 ))
1958
1959(ert-deftest bytecomp--byte-op-error-backtrace ()
1960 "Check that signalling byte ops show up in the backtrace."
1961 (dolist (case bytecomp-tests--byte-op-error-cases)
1962 (ert-info ((prin1-to-string case) :prefix "case: ")
1963 (let* ((call (nth 0 case))
1964 (expected-error (nth 1 case))
1965 (fun-sym (car call))
1966 (actuals (cdr call)))
1967 ;; Test both calling the function directly, and calling
1968 ;; a byte-compiled η-expansion (lambda (ARGS...) (FUN ARGS...))
1969 ;; which should turn the function call into a byte-op.
1970 (dolist (byte-op '(nil t))
1971 (ert-info ((prin1-to-string byte-op) :prefix "byte-op: ")
1972 (let* ((fun
1973 (if byte-op
1974 (let* ((nargs (length (cdr call)))
1975 (formals (mapcar (lambda (i)
1976 (intern (format "x%d" i)))
1977 (number-sequence 1 nargs))))
1978 (byte-compile
1979 `(lambda ,formals (,fun-sym ,@formals))))
1980 fun-sym))
1981 (error-frame (bytecomp-tests--error-frame fun actuals)))
1982 (should (consp error-frame))
1983 (should (equal (car error-frame) (list 'error expected-error)))
1984 (let ((frame (cdr error-frame)))
1985 (should (equal (type-of frame) 'backtrace-frame))
1986 (should (equal (cons (backtrace-frame-fun frame)
1987 (backtrace-frame-args frame))
1988 call))))))))))
1989
1932;; Local Variables: 1990;; Local Variables:
1933;; no-byte-compile: t 1991;; no-byte-compile: t
1934;; End: 1992;; End: