unreach1.scm 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. (define (bar1)
  2. (if (primitive-throw (java.lang.NullPointerException)) (list 23) 11))
  3. ;; Diagnostic: unreach1.scm:2:58: warning - unreachable code
  4. (define (bar2)
  5. (list (primitive-throw (java.lang.NullPointerException)) 12 13))
  6. ;; Diagnostic: unreach1.scm:6:3: warning - unreachable procedure call
  7. ;; Diagnostic: unreach1.scm:6:9: note - this operand never finishes
  8. (define (bar3)
  9. (list 12 (primitive-throw (java.lang.NullPointerException)) (sqrt 13)))
  10. ;; Diagnostic: unreach1.scm:11:3: warning - unreachable procedure call
  11. ;; Diagnostic: unreach1.scm:11:12: note - this operand never finishes
  12. (define (bar4)
  13. (primitive-throw (java.lang.NullPointerException))
  14. 13)
  15. ;; Diagnostic: unreach1.scm:17:3: warning - unreachable code
  16. (define (bar5)
  17. (begin (primitive-throw (java.lang.NullPointerException))
  18. 13))
  19. ;; Diagnostic: unreach1.scm:22:10: warning - unreachable code
  20. ;;; Savannah bug #35524: Unreachable code is not an error
  21. (define (foo)
  22. (call-with-current-continuation
  23. (lambda (return)
  24. (let l ()
  25. (return #f)
  26. (l)))))
  27. ;; Diagnostic: unreach1.scm:31:8: warning - unreachable code
  28. ;;; Savannah bug #36560: eq? <endless-loop>
  29. (define (foo36560)
  30. (eq? (let loop () (loop)) #t))
  31. ;; Diagnostic: unreach1.scm:36:3: warning - unreachable procedure call
  32. ;; Diagnostic: unreach1.scm:36:8: note - this operand never finishes
  33. (define (let1 x y)
  34. (let ((a (list x y))
  35. (b (primitive-throw (java.lang.NullPointerException))))
  36. (list a b)))
  37. ;; Diagnostic: unreach1.scm:42:12: warning - initialization of b never finishes
  38. (define (let2 x y)
  39. (fluid-let ((a (list x y))
  40. (b (primitive-throw (java.lang.NullPointerException))))
  41. (list a b)))
  42. ;; Diagnostic: unreach1.scm:48:18: warning - initialization of b never finishes
  43. (define (let3 x y)
  44. (let ((a (primitive-throw (java.lang.NullPointerException)))
  45. (b (list x y)))
  46. (list a b)))
  47. ;; Diagnostic: unreach1.scm:53:12: warning - initialization of a never finishes
  48. ;;; Savannah bug #40123: Nested with-compile-options problem
  49. (define (nested-with-compile-options)
  50. (with-compile-options warn-unreachable: #f
  51. (let ((one "one") (two "two"))
  52. (with-compile-options warn-unreachable: #f
  53. (if (primitive-throw (java.lang.NullPointerException)) one two)))
  54. (if (primitive-throw (java.lang.NullPointerException)) 1 2)))
  55. (try-catch
  56. (begin (nested-with-compile-options)
  57. (format #t "nested-with-compile-options finished.~%"))
  58. (ex java.lang.NullPointerException
  59. (format #t "nested-with-compile-options threw NullPointerException.~%")))
  60. ;; Output: nested-with-compile-options threw NullPointerException.
  61. (define loop (lambda ()
  62. (let loop ((n 1))
  63. (loop (+ n 1)))))
  64. (define (e x)
  65. (case x
  66. ((1) (loop))
  67. ((2 3 4 5) (loop))
  68. ((#\a) (loop))))
  69. (try-catch (display (e 6))
  70. (exc java.lang.ClassCastException (lambda () (#!void))))
  71. ;; Diagnostic: unreach1.scm:81:12: warning - unreachable procedure call
  72. ;; Diagnostic: unreach1.scm:81:21: note - this operand never finishes