impc:ti:closure-in-first-position   scheme

Defined in:


(define impc:ti:closure-in-first-position
  (lambda (ast vars kts request?)
    ;; (println 'ast ast 'request? request?)
    ;; first check return type of car ast (which will be a closure)
    ;; then check against it's arg types
    (let ((type (impc:ti:type-check (car ast) vars kts request?)))
      (if (and (not (impc:ir:closure? type))
               (list? type)
               (impc:ir:closure? (car type)))
          (set! type (car type)))
      (if (not (impc:ir:type? type))
          '(()) ;;(list *impc:ir:notype*)
            (if (null? type)
                (impc:compiler:print-bad-type-error "unknown-type" ast))
            (if (not (list? type))
                (impc:compiler:print-bad-type-error (impc:ir:pretty-print-type type) ast))
            (if (<> (length (cddr type)) (length (cdr ast)))
                (impc:compiler:print-bad-arity-error ast))
            (if (<> (+ *impc:ir:closure* *impc:ir:pointer* *impc:ir:pointer*) (car type))
                (impc:compiler:print-bad-type-error (impc:ir:pretty-print-type (car type)) ast)
                (begin (map (lambda (a b)
                              (impc:ti:type-check b vars kts a))
                            (cddr type)
                            (cdr ast))
                       (cadr type))))))))

Back to Index