diff options
author | Andy Wingo <wingo@pobox.com> | 2016-06-24 17:35:55 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2016-06-24 17:37:51 +0200 |
commit | 229d062f83d7c79fa08729330406d25755b25080 (patch) | |
tree | 16c6218e563768a215c81b1be119ce40ff888ad4 /module/language/tree-il/peval.scm | |
parent | ff5cafc77d34420b12a134ef2c1d5bd7ca4794cb (diff) | |
download | guile-229d062f83d7c79fa08729330406d25755b25080.tar.gz |
Constant-folding eq? and eqv? uses deduplication
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
* module/language/tree-il/peval.scm (peval): Constant-fold eq? and eqv?
using equal?, anticipating deduplication.
Diffstat (limited to 'module/language/tree-il/peval.scm')
-rw-r--r-- | module/language/tree-il/peval.scm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm index 8e1069d38..7d1945873 100644 --- a/module/language/tree-il/peval.scm +++ b/module/language/tree-il/peval.scm @@ -511,7 +511,15 @@ top-level bindings from ENV and return the resulting expression." (lambda () (call-with-values (lambda () - (apply (module-ref the-scm-module name) args)) + (case name + ((eq? eqv?) + ;; Constants will be deduplicated later, but eq? + ;; folding can happen now. Anticipate the + ;; deduplication by using equal? instead of eq?. + ;; Same for eqv?. + (apply equal? args)) + (else + (apply (module-ref the-scm-module name) args)))) (lambda results (values #t results)))) (lambda _ |