[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
two bugs in reference implementation
- To: srfi-99@xxxxxxxxxxxxxxxxx
- Subject: two bugs in reference implementation
- From: Derick Eddington <derick.eddington@xxxxxxxxx>
- Date: Fri, 06 Nov 2009 15:26:43 -0800
- Delivered-to: srfi-99@xxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=qpdscG/U6R4p63gtSZeXcJcjpDXBM6DCBT2q0D5IJW4=; b=UvD++rBuYxXd3kB+yXTH9J9ENQjrBxAAn8GT5a/AcTmg7+de1G+5optmwf5VMrqva9 30Nh15PLnvamdpC+SwiB+EVXRzsk/iQHua0ncjODnYJFvAOTkkEBCaWrxN0EirwQwdxD +4zNfGISNCQa+BMM0umsiugMPyY83pT0NVnM0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=jxjIAviXxgHKyy40bJhyzyCahv8GBETt2cVO6vK9QwTkfh5gf4M2UAQyiEcRFPFyiO 8zQtnHsi7llZVjIlhkOLDcv1NhzyhP0dS7Re8WRFRw8+X0JD5+me7nGAbveZlrYFpys5 1jU6D1PxMnGFQvv8V+cnxMkLRSSJPI1ioyKo8=
I've found and fixed two bugs in the reference implementation currently
at http://srfi.schemers.org/srfi-99/srfi-99.sls .
First one:
Ikarus Scheme version 0.0.4-rc1+ (revision 1865, build 2009-10-21)
Copyright (c) 2006-2009 Abdulaziz Ghuloum
> (load "srfi-99.sls")
> (import (srfi :99 records))
> (define-record-type point #T #T (x) (y))
Exception trapped by debugger.
Condition components:
1. &assertion
2. &who: map
3. &message: "not a proper list"
4. &irritants: ()
[t] Trace. [r] Reraise exception. [c] Continue. [q] Quit. [?] Help.
>> t
CALL FRAMES:
FRAME 0:
[0] (map (lambda (fspec field-spec) (cond ((symbol? fspec) (list 'immutable fspec (string->symbol (string-append type-name-string "-" (symbol->string fspec))))) ((not (pair? fspec)) (complain)) ((not (list? fspec)) (complain)) ((not (for-all symbol? fspec)) (complain)) ((null? (cdr fspec)) (list 'mutable (car fspec) (string->symbol (string-append type-name-string "-" (symbol->string (car fspec)))) (string->symbol (string-append type-name-string "-" (symbol->string (car fspec)) "-set!")))) ((null? (cddr fspec)) (list 'immutable (car fspec) (syntax-car (syntax-cdr field-spec)))) ((null? (cdddr fspec)) (list 'mutable (car fspec) (syntax-car (syntax-cdr field-spec)) (syntax-car (syntax-cdr (syntax-cdr field-spec))))) (else (complain)))) fspecs (syntax->list #'field-specs))
operator: #<procedure map>
operands: (#<procedure> ((x) (y)) (#<syntax (x)> . #<syntax ((y))>))
>>
After fixing the above one by modifying syntax->list (see the below
patch), I found the second one:
> (load "srfi-99.sls")
> (import (srfi :99 records))
> (define-record-type point #T #T (x) (y))
Unhandled exception
Condition components:
1. &message: "invalid expression"
2. &syntax:
form: #<syntax #f>
subform: #f
3. &trace: #<syntax #<syntax #f>>
>
The bug with this one is doing datum->syntax on syntax objects. I fixed
it by modifying frob (see the below patch).
--- srfi-99.sls 2009-11-06 15:11:20.000000000 -0800
+++ srfi-99.sls--Derick 2009-11-06 15:09:05.000000000 -0800
@@ -223,8 +223,10 @@
(cons (frob (car x)) (frob (cdr x))))
((vector? x)
(vector-map frob x))
+ ((symbol? x)
+ (datum->syntax tname x))
(else
- (datum->syntax tname x))))
+ x)))
#`(#,(frob #'define-record-type-helper)
#,(frob tname)
@@ -258,9 +260,7 @@
(define (syntax->list x)
(syntax-case x ()
(()
- x)
- ((x0)
- x)
+ '())
((x0 . x1)
(cons #'x0 (syntax->list #'x1)))))
--
: Derick
----------------------------------------------------------------