From e08f3f7a303f77c2e9ed41b69b2d6a5205be6668 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 24 Jul 2007 23:17:54 +0000 Subject: [PATCH] Changes from arch/CVS synchronization --- ChangeLog | 4 ++++ NEWS | 4 ++++ libguile/ChangeLog | 6 +++++ libguile/eval.c | 41 +++++++++++++++++++---------------- test-suite/ChangeLog | 13 ++++++++--- test-suite/tests/srfi-17.test | 17 ++++++++++++++- 6 files changed, 62 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index db9546de0..c6b06b4db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-07-25 Ludovic Courtès + + * NEWS: Mention bug fix for "(set! 'x #f)". + 2007-07-22 Ludovic Courtès * configure.in: Check for and `strncasecmp ()'. diff --git a/NEWS b/NEWS index 15f2d80cd..92b1f0e6f 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,10 @@ Changes in 1.8.3 (since 1.8.2) ** `(srfi srfi-37)' +* Bugs fixed + +** Expressions like "(set! 'x #t)" no longer yield a crash + Changes in 1.8.2 (since 1.8.1): diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 328e6ec4e..1fe371b5e 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2007-07-25 Ludovic Courtès + + * eval.c (macroexp): When `scm_ilength (res) <= 0', return + immediately. This used to produce a circular memoized + expression, e.g., for `(set (quote x) #t)'. + 2007-07-22 Ludovic Courtès Overhauled the reader, making it faster. diff --git a/libguile/eval.c b/libguile/eval.c index 24bd7cd5f..64266151f 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -874,26 +874,29 @@ macroexp (SCM x, SCM env) SCM_SETCAR (x, orig_sym); /* Undo memoizing effect of lookupcar */ res = scm_call_2 (SCM_MACRO_CODE (proc), x, env); - - if (scm_ilength (res) <= 0) - res = scm_list_2 (SCM_IM_BEGIN, res); - - /* njrev: Several queries here: (1) I don't see how it can be - correct that the SCM_SETCAR 2 lines below this comment needs - protection, but the SCM_SETCAR 6 lines above does not, so - something here is probably wrong. (2) macroexp() is now only - used in one place - scm_m_generalized_set_x - whereas all other - macro expansion happens through expand_user_macros. Therefore - (2.1) perhaps macroexp() could be eliminated completely now? - (2.2) Does expand_user_macros need any critical section - protection? */ - - SCM_CRITICAL_SECTION_START; - SCM_SETCAR (x, SCM_CAR (res)); - SCM_SETCDR (x, SCM_CDR (res)); - SCM_CRITICAL_SECTION_END; - goto macro_tail; + if (scm_ilength (res) <= 0) + /* Result of expansion is not a list. */ + return (scm_list_2 (SCM_IM_BEGIN, res)); + else + { + /* njrev: Several queries here: (1) I don't see how it can be + correct that the SCM_SETCAR 2 lines below this comment needs + protection, but the SCM_SETCAR 6 lines above does not, so + something here is probably wrong. (2) macroexp() is now only + used in one place - scm_m_generalized_set_x - whereas all other + macro expansion happens through expand_user_macros. Therefore + (2.1) perhaps macroexp() could be eliminated completely now? + (2.2) Does expand_user_macros need any critical section + protection? */ + + SCM_CRITICAL_SECTION_START; + SCM_SETCAR (x, SCM_CAR (res)); + SCM_SETCDR (x, SCM_CDR (res)); + SCM_CRITICAL_SECTION_END; + + goto macro_tail; + } } /* Start of the memoizers for the standard R5RS builtin macros. */ diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index af14831fc..80975aa2c 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,10 @@ +2007-07-25 Ludovic Courtès + + * tests/srfi-17.test (%some-variable): New. + (set!)[target uses macro]: New test prefix. The + "(set! (@@ ...) 1)" test is in accordance with Marius Vollmer's + change in `libguile' dated 2003-11-17. + 2007-07-22 Ludovic Courtès * tests/reader.test: Added a proper header and `define-module'. @@ -140,7 +147,7 @@ * tests/numbers.test (*): Exercise multiply by exact 0 giving exact 0. -2006-12-12 Ludovic Courtès +2006-12-12 Ludovic Courtès * tests/unif.test (syntax): New test prefix. Check syntax for negative lower bounds and negative lengths (reported by Gyula @@ -167,7 +174,7 @@ ensure intended exact vs inexact is checked. Reported by Aaron M. Ucko, Debian bug 396119. -2006-11-29 Ludovic Courtès +2006-11-29 Ludovic Courtès * test-suite/tests/vectors.test: Use `define-module'. (vector->list): New test prefix. "Shared array" test contributed @@ -187,7 +194,7 @@ * tests/environments.test: Comment out all tests in this file. -2006-10-26 Ludovic Courtès +2006-10-26 Ludovic Courtès * tests/srfi-14.test (Latin-1)[char-set:punctuation]: Fixed a typo: `thrown' instead of `throw'. diff --git a/test-suite/tests/srfi-17.test b/test-suite/tests/srfi-17.test index 0a0b42541..fbacb15a3 100644 --- a/test-suite/tests/srfi-17.test +++ b/test-suite/tests/srfi-17.test @@ -48,6 +48,8 @@ ;; set! ;; +(define %some-variable #f) + (with-test-prefix "set!" (with-test-prefix "target is not procedure with setter" @@ -58,7 +60,20 @@ (pass-if-exception "(set! '#f 1)" exception:bad-variable - (eval '(set! '#f 1) (interaction-environment))))) + (eval '(set! '#f 1) (interaction-environment)))) + + (with-test-prefix "target uses macro" + + (pass-if "(set! (@@ ...) 1)" + (eval '(set! (@@ (test-suite test-srfi-17) %some-variable) 1) + (interaction-environment)) + (equal? %some-variable 1)) + + ;; The `(quote x)' below used to be memoized as an infinite list before + ;; Guile 1.8.3. + (pass-if-exception "(set! 'x 1)" + exception:bad-variable + (eval '(set! 'x 1) (interaction-environment))))) ;; ;; setter -- 2.20.1