(define impc:ti:vector-set-check
(lambda (ast vars kts request?)
;(println 'ast: ast 'vars: vars)
(if (<> (length ast) 4)
(impc:compiler:print-bad-arity-error ast))
(let* ((a (impc:ti:type-check (cadr ast) vars kts #f))
;; b should be i32
(b (impc:ti:type-check (caddr ast) vars kts (list *impc:ir:si32*)))
;; c should be of type a*
(c (impc:ti:type-check (cadddr ast) vars kts (if (null? a) #f (list (caddr (car a)))))))
(if (or (and (not (null? a))
(impc:ir:type? (car a))
(not (impc:ir:vector? (car a))))
(and (not (null? a))
(impc:ir:type? (car a))
(> (impc:ir:get-ptr-depth (car a)) 1)))
(impc:compiler:print-bad-type-error (impc:ir:get-type-str (car a))))
;; vector set returns a whole new vector! check llvm ir doc
a)))