From: Owen Rodley Date: Mon, 3 Jun 2013 01:09:49 +0000 (+1200) Subject: Fix #111, error with docstrings containing single quotes X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=76337cf1599389fdf8ab3f1c40a5f62b123a6237;p=jscl.git 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 --- 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))