Subject: bug#73270: 31.0.50; comp.el comp--type-check-optim pass causes issues

From: Andrea Corallo <[email-masked]>
Date: Tue, 15 Oct 2024 04:35:09 -0400

Here is my minimal reproducer so far:

test.el===============
;; -*- lexical-binding: t; -*-
(require 'cl-lib)
(cl-defstruct base)
(cl-defstruct
    (child1 (:include base)))
(cl-defstruct
    (child2 (:include base)))
(cl-defstruct
    (child3 (:include base)))
(cl-defstruct
    (child4 (:include base)))

(defun foo (x)
  (message "type-of x: %S, x = %S" (type-of x) x)
  (cl-typecase x
    (child1
     (message "match: child1"))
    (child2
     (message "match: child2"))
    (child3
     (message "match: child3"))
    (child4
     (message "match: child4"))))

=============

(progn
  (load (native-compile "test.el"))
  (foo (make-child4)))

evaluates to : "match: child3"

I'm looking into it.

  Andrea