From: Vladimir Sedach Date: Mon, 27 Apr 2009 21:52:55 +0000 (-0600) Subject: Fixed bug in keyword argument handling (patch thanks to Red Daly). X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/62ddca2303bd31a1597eaa57e1d7cef37caef2a3 Fixed bug in keyword argument handling (patch thanks to Red Daly). --- diff --git a/src/compilation-interface.lisp b/src/compilation-interface.lisp index e715279..6851eeb 100644 --- a/src/compilation-interface.lisp +++ b/src/compilation-interface.lisp @@ -1,6 +1,6 @@ (in-package "PARENSCRIPT") -(defvar *js-target-version* 1.3) +(defparameter *js-target-version* 1.3) (defmacro ps (&body body) "Given Parenscript forms (an implicit progn), compiles those forms diff --git a/src/special-forms.lisp b/src/special-forms.lisp index e2bda58..a6d363f 100644 --- a/src/special-forms.lisp +++ b/src/special-forms.lisp @@ -228,7 +228,7 @@ Syntax of key spec: " (let* ((var (cond ((symbolp key-spec) key-spec) ((and (listp key-spec) (symbolp (first key-spec))) (first key-spec)) - ((and (listp key-spec) (listp (first key-spec))) (second key-spec)))) + ((and (listp key-spec) (listp (first key-spec))) (second (first key-spec))))) (keyword-name (if (and (listp key-spec) (listp (first key-spec))) (first (first key-spec)) (intern (string var) :keyword))) diff --git a/t/ps-tests.lisp b/t/ps-tests.lisp index c883c91..6d4ab8a 100644 --- a/t/ps-tests.lisp +++ b/t/ps-tests.lisp @@ -446,6 +446,26 @@ __setf_someThing(_js1, _js2, _js3);") return baz * bar; }") +(test-ps-js defun-keyword4 + (defun hello-world (&key ((:my-name-key my-name) 1)) + my-name) + "function helloWorld() { + var myName; + var _js3 = arguments.length; + for (var n1 = 0; n1 < _js3; n1 += 2) { + switch (arguments[n1]) { + case 'my-name-key': + { + myName = arguments[n1 + 1]; + }; + }; + }; + if (myName === undefined) { + myName = 1; + }; + myName; +}") + (test-ps-js keyword-funcall1 (func :baz 1) "func('baz', 1)")