From dd5c372ff8e6375bea245526ed653796b4aa8030 Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Tue, 30 Mar 2021 23:04:04 +0200 Subject: [PATCH] cmp: fix let bindings with initforms which are lists with QUOTE symbol as first element Example: (let ((x '(quote ...))) ...) We really have to quote the value in all cases, si::maybe-quote would strip away one level of quotation leaving only the equivalent of (let ((x (quote ...))) ...) which of course is incorrect. --- src/cmp/cmplet.lsp | 2 +- src/tests/normal-tests/compiler.lsp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cmp/cmplet.lsp b/src/cmp/cmplet.lsp index 56e6488a4..57d2dd30d 100644 --- a/src/cmp/cmplet.lsp +++ b/src/cmp/cmplet.lsp @@ -108,7 +108,7 @@ (multiple-value-bind (constantp value) (c1form-constant-p init) (when constantp - (cmp-env-register-symbol-macro name (si::maybe-quote value)) + (cmp-env-register-symbol-macro name `',value) (setf var nil)))) (when var (push var vars) diff --git a/src/tests/normal-tests/compiler.lsp b/src/tests/normal-tests/compiler.lsp index 2291b89a4..1069cbe74 100644 --- a/src/tests/normal-tests/compiler.lsp +++ b/src/tests/normal-tests/compiler.lsp @@ -2037,3 +2037,12 @@ '((1 1 nil nil nil) (1 2 nil nil nil) (1 2 (:d 3) 3 3))))) + +;;; Date 2021-03-30 +;;; Description +;;; +;;; let bindings of lists like '(quote ...) were miscompiled +(test cmp.0087.let-list-containing-quote + (is (equal '((quote) (quote a b c)) + (funcall + (compile nil '(lambda () (let ((x '(quote)) (y '(quote a b c))) (list x y))))))))