(define impc:ti:array-ref-check
(lambda (ast vars kts request?)
;;(println 'request? request?)
;;(println 'array-ref-check: 'ast: ast 'vars: vars 'kts: kts)
(if (<> (length ast) 3)
(impc:compiler:print-bad-arity-error ast))
(let ((a (impc:ti:type-check (cadr ast) vars kts '()))
;; b should be fixed point
(b (impc:ti:type-check (caddr ast) vars kts (list *impc:ir:si64* *impc:ir:si32*))))
(if (impc:ir:type? a) (set! a (list a)))
(if (null? a)
a
(if (or (not (impc:ir:array? (car a)))
(> (impc:ir:get-ptr-depth (car a)) 1))
(impc:compiler:print-bad-type-error (impc:ir:get-type-str (car a)))
(list (caddr (car a))))))))