No longer allow PROGV to bind constants

PROGV was allowed to bind constants in the C-compiler and the bytecode
compiler and interpreter, but the behavior would differ between them:

> (defun foo ()
    (flet ((memq (item list) (member item list :test #'eq)))
      (progv (list :test) (list :test-not)
        (memq 'bar '(bar baz quux)))))
FOO

> (foo)
(BAZ QUUX)

> (compile 'foo)
FOO

> (foo)
(BAR BAZ QUUX)

CLHS says the behavior is undefined when attempting to bind or assign
constant variables (CLHS 3.1.2.1.1.3 and the entry for defconstant).

The C-compiler and bytecode compiler and interpreter give errors when
attempting to bind or assign constant variables in lambda expressions,
LET, SETQ and various other binding/assignment forms.  So the behavior
above in PROGV is inconsistent.

Now give an error when attempting to bind a constant variable in PROGV
in the C-compiler and the bytecode compiler and interpreter.
This commit is contained in:
Kris Katterjohn 2017-06-27 18:46:55 -05:00
parent c9e7326275
commit 4e3283706f

View file

@ -198,7 +198,7 @@ ecl_progv(cl_env_ptr env, cl_object vars0, cl_object values0)
return n;
} else {
cl_object var = ECL_CONS_CAR(vars);
if (!ECL_SYMBOLP(var))
if (!ECL_SYMBOLP(var) || (ecl_symbol_type(var) & ecl_stp_constant))
FEerror("Not a valid variable name ~S.", 1, var);
if (Null(values)) {
ecl_bds_bind(env, var, OBJNULL);