Commit da859328 authored by Vladimir Sedach's avatar Vladimir Sedach

Fixed error with symbol-macrolet overriding lexical bindings introduced by...

Fixed error with symbol-macrolet overriding lexical bindings introduced by functions. Thanks to Scott Bell for the bug report.
parent 0f79f2f7
......@@ -147,7 +147,8 @@ CL environment)."
(defpsmacro ,name ,args ,@body)))
(defun ps-macroexpand-1 (form)
(aif (or (and (symbolp form) (lookup-macro-def form *symbol-macro-env*))
(aif (or (and (symbolp form) (or (and (member form *enclosing-lexicals*) (lookup-macro-def form *symbol-macro-env*))
(gethash form *symbol-macro-toplevel*))) ;; hack
(and (consp form) (lookup-macro-def (car form) *macro-env*)))
(values (ps-macroexpand (funcall it form)) t)
form))
......
......@@ -113,7 +113,7 @@ Syntax of key spec:
(defun compile-function-body (args body)
(with-declaration-effects (body body)
(let* ((*enclosing-lexical-block-declarations* ())
(*enclosing-lexicals* (append args *enclosing-lexicals*))
(*enclosing-lexicals* (set-difference *enclosing-lexicals* args))
(body (let ((in-loop-scope? nil)
(*loop-scope-lexicals* ())
(*loop-scope-lexicals-captured* ()))
......
......@@ -2527,7 +2527,9 @@ foo = 3;")
};")
(test-ps-js loop-closures-let
(dotimes (i 10) (let ((x (+ i 1))) (lambda () (+ i x))))
(dotimes (i 10)
(let ((x (+ i 1)))
(lambda () (+ i x))))
"for (var i = 0; i < 10; i += 1) {
with ({ x : null, i : i }) {
var x = i + 1;
......@@ -2806,3 +2808,38 @@ foo = 3;")
return foo7();
};
};")
(test-ps-js let-let-funcall-lambda
(let ((x 5))
(let ((x 7))
(funcall (lambda (x) (+ x 9)) x)))
"var x = 5;
var x1 = 7;
(function (x) {
return x + 9;
})(x1);")
(test-ps-js let-let-lambda
(let ((x 5))
(let ((x 7))
(lambda (x) (+ x 9))))
"var x = 5;
var x1 = 7;
function (x) {
return x + 9;
};")
(test-ps-js let-lambda
(let ((x 5))
(lambda (x) (+ x 9)))
"var x = 5;
function (x) {
return x + 9;
};")
(test-ps-js symbol-macrolet-no-shadow-lambda
(symbol-macrolet ((x y))
(lambda (x) (+ x x)))
"function (x) {
return x + x;
};")
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