(module m typed/racket (provide g foo) (: g (U String Boolean)) ; <- annotate g to be (or string boolean) (define g "a") (define (foo) (string-append g)) ;; globals.rkt:6:17: Type Checker: type mismatch ;; expected: String ;; given: (U Boolean String) ;; in: g ;; ^^ no warnings without the type annotation ;; (define (foo) ;; (if (string? g) ;; (+ 1 g) ;; "else")) ;; globals.rkt:19:12: Type Checker: type mismatch ;; expected: Number ;; given: String ;; in: g ;; ^^ this happens even without the type annotation )