unreach3.scm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. (format #t "[~a]~%"
  2. (* 10 (call/cc (lambda (k) (+ 2 (k 3))))))
  3. ;; Diagnostic: unreach3.scm:2:36: warning - unreachable procedure call
  4. ;; Diagnostic: unreach3.scm:2:41: note - this operand never finishes
  5. ;30
  6. ;; Output: [30]
  7. (format #t "is-procedure: ~a~%"
  8. (procedure?
  9. (let ()
  10. (define aa 20)
  11. (define (foo) aa)
  12. (define (bar)
  13. (let loop ((arg 'bar))
  14. (foo)
  15. (not (loop (foo)))))
  16. bar)))
  17. ;; Diagnostic: unreach3.scm:16:16: warning - unreachable procedure call
  18. ;; Diagnostic: unreach3.scm:16:21: note - this operand never finishes
  19. ;; Output: is-procedure: #t
  20. (define (test-catch)
  21. (let* ((x 0)
  22. (y (catch 'key
  23. (lambda ()
  24. (set! x 2)
  25. (throw 'key 10)
  26. (set! x 1000))
  27. (lambda (key arg)
  28. (set! x (* x arg))
  29. (+ x 10)))))
  30. (list x y)))
  31. ;; Diagnostic: unreach3.scm:28:8: warning - unreachable code
  32. (format #t "test-catch: ~s~%"
  33. (test-catch))
  34. ;; Output: test-catch: (20 30)
  35. ;; Savannah bug #32678: set! and endless loop
  36. (define (foo-savannah-32678 x)
  37. (let ((fail 0)
  38. (result #!null))
  39. (if (instance? x pair)
  40. (set! result (do () (#f)))
  41. (set! fail -1))
  42. (if (= fail 0)
  43. result
  44. #f)))
  45. (format #t "foo-savannah-32678: ~w~%" (foo-savannah-32678 123))
  46. ;; Diagnostic: unreach3.scm:43:15: warning - 'result' can never be set because expression never finishes
  47. ;; Output: foo-savannah-32678: #f