The following code works fine with `M-x eval-buffer`, and byte-compiles without any warnings.

```lisp
(eval-when-compile
  (defconst demo-one 1))

(defvar demo-some-var
  `(foo bar ,demo-one))

```

However, if I byte compile it, I get broken code:

```
;ELC
;;; Compiled
;;; in Emacs version 26.1
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.

;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar demo-some-var (list 'foo 'bar demo-one))

```

The byte compiler hasn't put `demo-one` in the .elc file, so anyone installing my package from (M)ELPA gets broken code.

I should be using `eval-and-compile` in this case, but I didn't realise my code was wrong. Can the byte compiler warn me here? Why didn't it?