~evhan/beaker

1b40867ad90a5cc67a9d6d842cd5b07062fd6cfb — Evan Hanson 3 years ago e8a0c76
Avoid nested-let warning for named lets
1 files changed, 12 insertions(+), 8 deletions(-)

M lib/beaker.scm
M lib/beaker.scm => lib/beaker.scm +12 -8
@@ 162,14 162,18 @@
      (warn 'unnecessary-quasiquote x)))

  (define (analyse-let x #!optional (type 'let))
    (let loop ((body (cddr x)))
      ;; check for (let () (let () ...))
      (when (and (pair? (car body)) (null? (cdr body)))
        (cond ((compiler-compare (caar body) 'scheme type)
               (warn (symbol-append 'nested- type) x))
              ((compiler-compare (caar body) 'scheme 'begin)
               (loop (cdar body)))
              (else (void))))))
    ; skip (let foo () (let () ...))
    (unless (symbol? (cadr x))
      (let loop ((body (cddr x)))
        ;; check for (let () (let () ...))
        (when (and (pair? (car body)))
          (cond ((compiler-compare (caar body) 'scheme type)
                 ;; skip (let () (let foo () ...))
                 (unless (and (eq? type 'let) (symbol? (cadar body)))
                   (warn (symbol-append 'nested- type) x)))
                ((compiler-compare (caar body) 'scheme 'begin)
                 (loop (cdar body)))
                (else (void)))))))

  (define (analyse-let* x)
    (analyse-let x 'let*)