uninit1.scm 717 B

1234567891011121314151617181920212223242526
  1. (module-compile-options warn-as-error: #t)
  2. (define (f1 x)
  3. (define y z)
  4. (define z (+ x 3))
  5. (list y z))
  6. ;; Diagnostic: uninit1.scm:3:13: variable 'z' may be uninitialized here
  7. (define (f2 x)
  8. (define x (apply (lambda () (* 2 y)) '()))
  9. (define y 10)
  10. (list x y))
  11. ;; Diagnostic: uninit1.scm:8:36: variable 'y' may be uninitialized here
  12. (define (f3 x)
  13. (define (y2) (* 2 y))
  14. (define y 10)
  15. (define x2 (y2))
  16. (list x2 y))
  17. ; No warning for f3!
  18. (define (f4 x)
  19. (define (y2) (* 2 y))
  20. (define x1 (y2))
  21. (define y 10)
  22. (define x2 (y2))
  23. (list x1 x2 y))
  24. ;; Diagnostic: uninit1.scm:19:21: variable 'y' may be uninitialized here
  25. ;; Diagnostic: uninit1.scm:20:15: - because of possible call here of function y2