Fix bug in has_free_vars_fn. Add optimization to type_checker.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>