1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

peval fix: (cons 1 #nil) is not (list 1)

* module/language/tree-il/peval.scm (peval): (cons FOO #nil) is not
  (cons FOO '()).

* test-suite/tests/tree-il.test ("partial evaluation"): Add a test.
This commit is contained in:
Andy Wingo 2011-12-21 22:04:18 -05:00
parent fff39e1aa5
commit cc8afa2b36
2 changed files with 6 additions and 1 deletions

View file

@ -1040,7 +1040,7 @@ top-level bindings from ENV and return the resulting expression."
(match (cons name (map for-value orig-args))
(('cons head tail)
(match tail
(($ <const> src ())
(($ <const> src (? (cut eq? <> '())))
(make-application src (make-primitive-ref #f 'list)
(list head)))
(($ <application> src ($ <primitive-ref> _ 'list) elts)

View file

@ -1419,6 +1419,11 @@
(((x) #f #f #f () (_))
(apply (toplevel top) (lexical x _)))))))
(pass-if-peval
;; Constant folding: cons of #nil does not make list
(cons 1 #nil)
(apply (primitive cons) (const 1) (const '#nil)))
(pass-if-peval
;; Constant folding: cons
(begin (cons 1 2) #f)