[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

byte-compiler warn on quote lexical var?

From: Stephen Leake
Subject: byte-compiler warn on quote lexical var?
Date: Tue, 04 Aug 2015 09:01:03 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

I've posted bug#21185; it suggests that the byte-compiler should warn
when a lexical variable is quoted.

For example, with this code:

;; -*- lexical-binding: t -*-

(defun display-var (var)
  "Display variable value of VAR (a symbol), if any."
   ((boundp var)
    (message "%s: %s" (symbol-name var) (symbol-value var)))

    (message "%s not bound" (symbol-name var)))))

(defun quote-lexical-var ()
  (let ((my-var "foo"))
    (message "non-quoted my-var: %s" my-var)
    (display-var 'my-var)))

the call to 'display-var' reports "not bound".

I've been bitten by this problem a couple of times when porting code to
lexical binding; I'd like the byte-compiler to warn me about it.

Is that reasonable?

Can anyone point me to where in the byte-compiler code I should look to
start working on adding this?

-- Stephe

reply via email to

[Prev in Thread] Current Thread [Next in Thread]