Fix #111, error with docstrings containing single quotes
authorOwen Rodley <Strigoides@gmail.com>
Mon, 3 Jun 2013 01:09:49 +0000 (13:09 +1200)
committerOwen Rodley <Strigoides@gmail.com>
Mon, 3 Jun 2013 01:16:28 +0000 (13:16 +1200)
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
tests/defun.lisp [new file with mode: 0644]

index 3a74399..362b84f 100644 (file)
       (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 (file)
index 0000000..39f945e
--- /dev/null
@@ -0,0 +1,4 @@
+;;;; Tests for DEFUN
+
+;;; Regression test for #111
+(test (eql (defun foo () "foo's" ()) 'foo))