convert-closures "free vars encountered in program" error mistakenly happening

Bug #178858 reported by Derick Eddington on 2007-12-27
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Critical
Abdulaziz Ghuloum

Bug Description

Sorry, I tried, but couldn't find a simpler way to reproduce this. I tried other snippets which do the same thing of binding an introduced gensym variable and referring to it to pass the value to a recursive use of the macro, and they all work. (srfi and-let) is pasted after the REPL session. I've marked the relevant syntax-case clause in the source code that is causing the problem.

Ikarus Scheme version 0.0.2patched+ (revision 1289, build 2007-12-25)
Copyright (c) 2006-2007 Abdulaziz Ghuloum

> (import (srfi and-let))
> (define x 123)
> (and-let* ([x])) ;;; This works
123
> (and-let* ([+]))
Unhandled exception
 Condition components:
   1. &error
   2. &who: convert-closures
   3. &message: "free vars encountered in program"
   4. &irritants: ((#["var" #{var |gevcu2y dn\bo2nlD|} #f #t #f #f #f #f #f #f #f #f #f]) (begin '#<void> '#<void> + (if v:var + '#f)))
>

====================================
(srfi and-let)
====================================

(library (srfi and-let)
  ;; can't be named (srfi and-let*) because some OS's filenames can't have *
  (export and-let*)
  (import (rnrs))

  (define-syntax and-let*
    (lambda (stx)

      (define (unique-ids? ls)
        (or (null? ls)
            (and (let notmem? ([x (car ls)] [ls (cdr ls)])
                   (or (null? ls)
                       (and (not (and (bound-identifier=? x (car ls))
                                      (syntax-violation #f "duplicate binding" stx x)))
                            (notmem? x (cdr ls)))))
                 (unique-ids? (cdr ls)))))

      (define (get-and-check-ids clauses)
        (let loop ([c* clauses])
          (syntax-case c* ()
            [([var expr] . rest)
             (or (identifier? #'var)
                 (syntax-violation #f "not an identifier" stx #'var))
             (cons #'var (loop #'rest))]
            [(whatever . rest)
             (loop #'rest)]
            [()
             '()])))

      ;;; First check these
      (syntax-case stx ()
        [(_ (clause* ...) body* ...)
         (unique-ids? (get-and-check-ids #'(clause* ...)))
         'ignore])

      ;;; Then construct output syntax
      (syntax-case stx ()
        [(_ (clause* ...) body* ...)
         #'(and-let*-core #t (clause* ...) body* ...)])))

  (define-syntax and-let*-core
    (lambda (stx)
      (syntax-case stx ()
        [(kw ignore ([var expr] clause* ...) body* ...)
         #'(let ([var expr])
             (if var
               (kw var (clause* ...) body* ...)
               #f))]
        [(kw ignore ([expr] clause* ...) body* ...) ;;; <=== This one ***
         (with-syntax ([(g) (generate-temporaries '(var))])
           #'(let ([g expr])
               (if g
                 (kw g (clause* ...) body* ...)
                 #f)))]
        [(kw ignore (id clause* ...) body* ...)
         (or (identifier? #'id)
             (syntax-violation #f "invalid clause" stx #'id))
         #'(if id
             (kw id (clause* ...) body* ...)
             #f)]
        [(kw last () body* ...)
         (if (positive? (length #'(body* ...)))
           #'(begin body* ...)
           #'last)])))
)

Abdulaziz Ghuloum (aghuloum) wrote :

Confirmed. This are simpler examples: (or + #f) or (let ([t +]) (if t t #f))

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Critical
status: New → Confirmed
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed in 1292. Thanks.

Changed in ikarus:
status: Confirmed → Fix Committed
Abdulaziz Ghuloum (aghuloum) wrote :

 This bug report is about to be closed as the fix comitted
previously will be incorporated in the next 0.0.3 release of
Ikarus Scheme, scheduled for January 31, 2008. A release
candidate tarball is available for download from:
http://www.cs.indiana.edu/~aghuloum/ikarus/ikarus-0.0.3-rc1.tar.gz
Please do test it if you have the time and report any issues
you might encounter. Thank you very much for your support.
(Sorry for the duplicates; I'm updating every open bug.)

Changed in ikarus:
milestone: none → 0.0.3
Changed in ikarus:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers