emacs-devel
[Top][All Lists]
Advanced

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

Re: about "assignment to free variable"


From: Stefan Monnier
Subject: Re: about "assignment to free variable"
Date: Tue, 05 Feb 2019 10:02:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> When i compile a piece of code the byte-compiler reports a warning
>> telling me that i'm trying to assign to a free variable:
>> But the variable in question is, atleast i think, referred to a local
>> variable because it is an argument of the function.
> I think your "at least I think" is in error.  But you'd have to show me
> the relevant code.

Looking at the current greader.el in your `master` branch, I suspect
you're talking about the warning

    In greader-change-backend:
    greader.el:203:18:Warning: assignment to free variable ‘backend’

where the problem is that this use of `backend` is within the
interactive spec: while the interactive spec is textually within the
definition of the function, it is code that's run outside of the
function (it's executed in order to build the list of arguments needed
to call the function).

So maybe the patch below would be the fix to this warning.


        Stefan


diff --git a/greader.el b/greader.el
index b854e0fa9..9491ac521 100644
--- a/greader.el
+++ b/greader.el
@@ -195,11 +195,12 @@ For example, if you specify a function that gets a 
sentence, you should specify
     (funcall greader-actual-backend command)))
 
 (defun greader-change-backend (&optional backend)
-  "changes back-end. if backend is specified, it changes to backend, else it 
cycles throwgh available back-ends."
+  "Change back-end.
+If BACKEND is specified, change to it, else cycle through available back-ends."
   (interactive
    (list
     (if current-prefix-arg
-       (setq backend (read-from-minibuffer "backend: ")))))
+       (read-from-minibuffer "backend: "))))
   (if (functionp backend)
       (if (memq backend greader-backends)
          (setq greader-actual-backend backend)




reply via email to

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