two bugs in reference implementation
Derick Eddington 06 Nov 2009 23:26 UTC
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
----------------------------------------------------------------