diff options
author | Andy Wingo <wingo@pobox.com> | 2011-12-21 22:04:18 -0500 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-12-21 22:04:18 -0500 |
commit | cc8afa2b361635953dfba7f10e4193b1f243a50f (patch) | |
tree | 6ad38522559a9df645cb89108579b9a13e07ec39 | |
parent | fff39e1aa5df70a65e78a3d49d6d841f58bafde7 (diff) | |
download | guile-cc8afa2b361635953dfba7f10e4193b1f243a50f.tar.gz |
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.
-rw-r--r-- | module/language/tree-il/peval.scm | 2 | ||||
-rw-r--r-- | test-suite/tests/tree-il.test | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm index dcdf189a2..a6bb954e2 100644 --- a/module/language/tree-il/peval.scm +++ b/module/language/tree-il/peval.scm @@ -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) diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test index de82340a4..0b00f6f8a 100644 --- a/test-suite/tests/tree-il.test +++ b/test-suite/tests/tree-il.test @@ -1420,6 +1420,11 @@ (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) (const #f)) |