Verified Commit 76f33d35 authored by Vladimir Sedach's avatar Vladimir Sedach
Browse files

Fix RETURN trying to grab declarations from body-less let/flet/etc

parent b513da9d
......@@ -3,6 +3,7 @@
;;; Copyright 2006 Luca Capello
;;; Copyright 2010-2012 Vladimir Sedach
;;; Copyright 2010-2013 Daniel Gackle
;;; Copyright 2012, 2014 Boris Smilga
;;; SPDX-License-Identifier: BSD-3-Clause
......
......@@ -287,10 +287,18 @@ invocations or not.")
((continue break throw) ;; non-local exit
form)
;; implicit progn forms
((with label let flet labels macrolet symbol-macrolet)
((with) ;; deprecated and will be removed
`(,(first form) ,(second form)
,@(butlast (cddr form))
(return-from ,tag ,(car (last (cddr form))))))
;; implicit body (declaration + progn) forms
((let flet labels macrolet symbol-macrolet)
(multiple-value-bind (body declarations)
(parse-body (cddr form))
`(,(first form) ,(second form)
,@declarations
,@(butlast body)
(return-from ,tag ,(car (last body))))))
(progn
`(progn ,@(butlast (cdr form))
(return-from ,tag ,(car (last (cdr form))))))
......@@ -462,8 +470,8 @@ Parenscript now implements implicit return, update your code! Things like (lambd
(define-expression-operator let (bindings &body body)
(with-declaration-effects (body body)
(flet ((rename (x) (first x))
(var (x) (second x))
(val (x) (third x)))
(var (x) (second x))
(val (x) (third x)))
(let* ((new-lexicals ())
(normalized-bindings
(mapcar (lambda (x)
......
......@@ -4054,6 +4054,34 @@ for (var i = 0; i < 5; i += 1) {
(or (not foo) (not (not foo)) (not (not (not foo))))
"!foo || foo || !foo;")
(test-ps-js empty-let
(defun foo ()
(let ((a (bar)))))
"function foo() {
var a = bar();
return null;
};")
(test-ps-js empty-let*
(defun foo ()
(let* ((a (bar)))))
"function foo() {
var a = bar();
return null;
};")
(test-ps-js defun-no-body-declare
(defun foo () (declare (ignore x)))
"function foo() {
return null;
};")
(test-ps-js defun-no-body-let-decare
(defun foo () (let () (declare (ignore x))))
"function foo() {
return null;
};")
(test-ps-js empty-defun-docstring-declare
(defun foo (x)
"docstring"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment