From 76337cf1599389fdf8ab3f1c40a5f62b123a6237 Mon Sep 17 00:00:00 2001 From: Owen Rodley Date: Mon, 3 Jun 2013 13:09:49 +1200 Subject: [PATCH] Fix #111, error with docstrings containing single quotes ESCAPE-STRING assumes the resulting string is going to be double-quoted, and LAMBA-NAME/DOCSTRING-WRAPPER was only single quoting them. A similar issue was present for function names with single quotes. These should be read differently, i.e. FO'O => FO (QUOTE O), but until the reader is fixed to deal with this I think allowing them in function names makes more sense than failing with a strange error message --- src/compiler.lisp | 4 ++-- tests/defun.lisp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 tests/defun.lisp diff --git a/src/compiler.lisp b/src/compiler.lisp index 3a74399..362b84f 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -266,9 +266,9 @@ (js!selfcall "var func = " (join strs) ";" *newline* (when name - (code "func.fname = '" (escape-string name) "';" *newline*)) + (code "func.fname = \"" (escape-string name) "\";" *newline*)) (when docstring - (code "func.docstring = '" (escape-string docstring) "';" *newline*)) + (code "func.docstring = \"" (escape-string docstring) "\";" *newline*)) "return func;" *newline*) (apply #'code strs))) diff --git a/tests/defun.lisp b/tests/defun.lisp new file mode 100644 index 0000000..39f945e --- /dev/null +++ b/tests/defun.lisp @@ -0,0 +1,4 @@ +;;;; Tests for DEFUN + +;;; Regression test for #111 +(test (eql (defun foo () "foo's" ()) 'foo)) -- 1.7.10.4