Commit fc2d9017 authored by Vladimir Sedach's avatar Vladimir Sedach
Browse files

Fixed bug where expressionize-if macroexpansion attempts would throw errors.

parent 9235eed0
......@@ -162,12 +162,12 @@
(t (warn "Returning from unknown block ~A" tag)
`(ps-js:return ,@cvalue))))) ;; for backwards-compatibility
(defun try-expressionizing-if? (exp &optional (score 0))
(defun try-expressionizing-if? (exp &optional (score 0)) ;; poor man's codewalker
(cond ((< 1 score) nil)
((listp exp)
(loop for x in (cdr exp) always
(try-expressionizing-if?
(ps-macroexpand x)
(or (ignore-errors (ps-macroexpand x)) x) ;; fail
(+ score (case (car exp)
((if cond let) 1)
((progn) (1- (length (cdr exp))))
......
......@@ -3453,6 +3453,23 @@ for (var x = null, _js_arrvar2 = [5, 2, 3], _js_idx1 = 0; _js_idx1 < _js_arrvar2
return loopResultVar3;
})();")
(test-ps-js expressionize-if-macroexpand-error
(progn (defmacro xbaz () `(blah))
(defun foo (xbaz)
(unless (blah)
(cond (xbaz (blah))
(t (blahblah))))))
"function foo(xbaz) {
if (!blah()) {
if (xbaz) {
return blah();
} else {
return blahblah();
};
};
};")
;;; broken
(test-ps-js let-defun-toplevel
......
Supports Markdown
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