]> git.eshelyaron.com Git - emacs.git/commit
Correctly eliminate duplicate cases in switch compilation
authorMattias Engdegård <mattiase@acm.org>
Fri, 17 May 2019 09:25:06 +0000 (11:25 +0200)
committerMattias Engdegård <mattiase@acm.org>
Mon, 27 May 2019 11:25:27 +0000 (13:25 +0200)
commit68b374a62d8b7b98fd0b144ae83077d698e20bdb
treee67783a51e27c314b7ddbc734b865beba0c8913a
parent457b02440510a594e3ff6f17cc6846a3a467a6a1
Correctly eliminate duplicate cases in switch compilation

Fix code mistakes that prevented the correct elimination of duplicated
cases when compiling a `cond' form to a switch bytecode, as in

  (cond ((eq x 'a) 1)
        ((eq x 'b) 2)
        ((eq x 'a) 3)   ; should be elided
        ((eq x 'c) 4))

Sometimes, this caused the bytecode to use the wrong branch (bug#35770).

* lisp/emacs-lisp/bytecomp.el (byte-compile-cond-vars): Return obj2 eval'ed.
(byte-compile-cond-jump-table-info):
Discard redundant condition.  Use `obj2' as evaluated.
Discard duplicated cases instead of failing the table generation.
* test/lisp/emacs-lisp/bytecomp-tests.el (toplevel): Require subr-x.
(byte-opt-testsuite-arith-data, bytecomp-test--switch-duplicates): Test.
lisp/emacs-lisp/bytecomp.el
test/lisp/emacs-lisp/bytecomp-tests.el