From 1ce4979658716eaae52a179c8943256cd0725f00 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 20 May 2024 19:31:38 -0700 Subject: [PATCH 1/3] Testing fix for issue #537 --- scheme/eval.sld | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scheme/eval.sld b/scheme/eval.sld index ba33ae11..042a520f 100644 --- a/scheme/eval.sld +++ b/scheme/eval.sld @@ -99,7 +99,9 @@ (cond ((application? exp) (cond - ((compound-procedure? (car exp)) + ((or (primitive-procedure? (car exp)) + (compound-procedure? (car exp)) + (procedure? (car exp))) (cons (car exp) (map From 06219634e9707f29d32c987375991f7bc7472908 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 21 May 2024 18:41:41 -0700 Subject: [PATCH 2/3] Issue #537 - Add useful comments --- scheme/eval.sld | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scheme/eval.sld b/scheme/eval.sld index 042a520f..5eafaa86 100644 --- a/scheme/eval.sld +++ b/scheme/eval.sld @@ -89,12 +89,19 @@ ((analyze exp *global-environment* rename-env '()) *global-environment*) ((analyze exp (car env) rename-env '()) (car env)))) +;; Called from the C runtime to support apply (define (eval-from-c exp . _env) (let ((env (if (null? _env) *global-environment* (car _env)))) (eval (wrapc exp) env))) -;; Expressions received from C code are already evaluated, but sometimes too much so. -;; Try to wrap +;; Helper function for eval-from-c +;; +;; Expressions received from C code are already evaluated, +;; however any quoted expressions will have the quotes +;; stripped off. This is a problem for expressions that +;; aren't self evaluating - like (1 2) - so we re-quote +;; the expressions here so a subsequent eval will work. +;; (define (wrapc exp) (cond ((application? exp) From bb6b3eafedc12b9c9ed936b4b02458e856ce5ec6 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 21 May 2024 18:54:17 -0700 Subject: [PATCH 3/3] Issue #537 - Document bug fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dc3dd80..96b43222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Bug Fixes +- Fixed a bug in `apply` where an error may be raised when processing quoted sub-expressions. For example the following would throw an error: `(apply cons '(5 (1 2)))`. Thanks to @srgx for the bug report! - Fixed a beta expansion optimization bug where code such as the following would cause the compiler to hang. Thanks to Yorick Hardy for the bug report: (define (compile-forever x) x (compile-forever x))