Hi Christian,

Christian Kellermann <ck...@pestilenz.org> writes:
> the attached patch fixes #805, by capturing the core length procedure
> correctly. Thanks go to Moritz for finding and reporting this issue.

I found yet another hygiene issue in `case-lambda' in the meantime and a
similar one in `ensure'. The attached patches address these also add
some regression tests.

Thanks again for your help!

Moritz
>From a441b07473a93f5216c31ae23dd993ff61958f15 Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp <mor...@twoticketsplease.de>
Date: Sun, 25 Mar 2012 14:24:07 +0200
Subject: [PATCH 1/3] Fix hygiene issues in `case-lambda'

This adresses bug #805
---
 chicken-syntax.scm |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index 08bede2..b634d1f 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -764,7 +764,8 @@
  `((>= . ,(##sys#primitive-alias '>=))
    (car . ,(##sys#primitive-alias 'car))
    (cdr . ,(##sys#primitive-alias 'cdr))
-   (eq? . ,(##sys#primitive-alias 'eq?)))
+   (eq? . ,(##sys#primitive-alias 'eq?))
+   (length . ,(##sys#primitive-alias 'length)))
  (##sys#er-transformer
   (lambda (form r c)
     (##sys#check-syntax 'case-lambda form '(_ . _))
@@ -785,11 +786,12 @@
 	   (%>= (r '>=))
 	   (%eq? (r 'eq?))
 	   (%car (r 'car))
-	   (%cdr (r 'cdr)))
+	   (%cdr (r 'cdr))
+	   (%length (r 'length)))
       `(##core#lambda
 	,(append minvars rvar)
 	(##core#let
-	 ((,lvar (length ,rvar)))
+        ((,lvar (,%length ,rvar)))
 	 ,(fold-right
 	   (lambda (c body)
 	     (##sys#decompose-lambda-list
@@ -820,7 +822,7 @@
 				     bindings
 				     `(##core#let ,(map list vars1 minvars) ,bindings) ) ) )
 			    ,body) ) ) )
-	   '(##core#check (##sys#error (##core#immutable '"no matching clause in call to 'case-lambda' form")))
+	   '(##core#check (##sys#error (##core#immutable (##core#quote "no matching clause in call to 'case-lambda' form"))))
 	   (cdr form))))))))
 
 
-- 
1.7.9.4

>From 7ef5a447cfdde5214b95a8648501e1483c33a805 Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp <mor...@twoticketsplease.de>
Date: Sun, 25 Mar 2012 14:24:19 +0200
Subject: [PATCH 2/3] Fix hygiene issue in `ensure'

---
 chicken-syntax.scm |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index b634d1f..2ea7072 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -208,8 +208,8 @@
 		    #:type-error
 		    ,@(if (pair? args)
 			  args
-			  `((##core#immutable '"argument has incorrect type")
-			    ,tmp ',pred) ) ) ) ) ) ) ) )
+			  `((##core#immutable (##core#quote "argument has incorrect type"))
+			    ,tmp (##core#quote ,pred)) ) ) ) ) ) ) ) )
 
 (##sys#extend-macro-environment
  'fluid-let '()
-- 
1.7.9.4

>From 75a09261c6ae737f6f42dd44bc737fcaa060186c Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp <mor...@twoticketsplease.de>
Date: Sun, 25 Mar 2012 14:24:35 +0200
Subject: [PATCH 3/3] Add regression tests for fixes introduced in a441b074
 and 7ef5a447

---
 tests/syntax-tests.scm |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm
index 21f57e5..bb2e2d2 100644
--- a/tests/syntax-tests.scm
+++ b/tests/syntax-tests.scm
@@ -967,3 +967,10 @@
 
 (use (prefix srfi-1 list-))
 take
+
+
+;; #805: case-lambda is unhygienic (as well as ensure, see c1160ca7 and 7fe07e9c)
+(module foo ()
+  (import (prefix chicken c/) (prefix scheme s/))
+  (c/case-lambda ((a) a))
+  (c/ensure s/even? 2))
-- 
1.7.9.4

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to