jscl-project / jscl

A Lisp-to-JavaScript compiler bootstrapped from Common Lisp
https://jscl-project.github.io
GNU General Public License v3.0
885 stars 109 forks source link

Backquote bug #492

Open hemml opened 6 months ago

hemml commented 6 months ago
CL-USER> `(1 . 2)
ERROR: CAR called on non-list argument
CL-USER> '(1 . 2)
(1 . 2)
hemml commented 6 months ago

Sorry for update, occasionally hit enter)

SuperDisk commented 6 months ago

Changing bq-attach-append in backquote.lisp to this seems to fix it:

(defun bq-attach-append (op item result)
  (cond ((and (null-or-quoted item) (null-or-quoted result))
         (if (atom (cadr item))
             (list *bq-quote* (cadr item))
             (list *bq-quote* (append (cadr item) (cadr result)))))
        ((or (null result) (equal result *bq-quote-nil*))
         (if (bq-splicing-frob item) (list op item) item))
        ((and (consp result) (eq (car result) op))
         (list* (car result) item (cdr result)))
        (t (list op item result))))
davazp commented 6 months ago

@SuperDisk nice, would you mind opening a PR for it? then we can make sure it passes tests and see the diff.

SuperDisk commented 6 months ago

Done, although I'm not 100% confident it's the right way to implement the fix. This project looks really cool by the way, I'd be really interested in hacking more on it if I get some time.