1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 02:00:26 +02:00

fix compilation of elisp forms with empty bodies

* module/language/elisp/compile-tree-il.scm (generate-let)
  (generate-let*, compile-lambda, compile-with-added-symbols)
  (compile-progn, compile-if): Return nil if the form's body is empty.
* test-suite/tests/elisp-compiler.test ("Sequencing")["empty progn"]:
  New test.
  ("Conditionals")["if with no else"]: New test.
  ("Let and Let*")["empty let, empty let*"]: New test.
  ("Lambda Expressions")["empty lambda"]: New test.
This commit is contained in:
BT Templeton 2011-06-20 23:04:45 -04:00
parent b652e2b93f
commit d5ac6923c3
2 changed files with 24 additions and 15 deletions

View file

@ -54,6 +54,9 @@
(setq a (1+ a))
a))
(pass-if-equal "empty progn" #nil
(progn))
(pass-if "prog1"
(progn (setq a 0)
(setq b (prog1 a (setq a (1+ a))))
@ -77,6 +80,9 @@
3)
(equal (if nil 1) nil)))
(pass-if-equal "if with no else" #nil
(if nil t))
(pass-if-equal "empty cond" nil-value
(cond))
(pass-if-equal "all failing cond" nil-value
@ -214,6 +220,8 @@
(b a))
b)))
(pass-if-equal "empty let" #nil (let ()))
(pass-if "let*"
(progn (setq a 0)
(and (let* ((a 1)
@ -225,6 +233,9 @@
(= a 0)
(not (boundp 'b)))))
(pass-if-equal "empty let*" #nil
(let* ()))
(pass-if "local scope"
(progn (setq a 0)
(setq b (let (a)
@ -397,7 +408,10 @@
(pass-if-equal "rest argument" '(3 4 5)
((lambda (a b &rest c) c) 1 2 3 4 5))
(pass-if-equal "rest missing" nil-value
((lambda (a b &rest c) c) 1 2)))
((lambda (a b &rest c) c) 1 2))
(pass-if-equal "empty lambda" #nil
((lambda ()))))
(with-test-prefix/compile "Function Definitions"