Swap remaining unsafe and chaperone-unsafe operation in the TR optimizer.

Fixes the fix in aba046a92d42.

original commit: 1d1d8bacad035fc1609f7444dd207a92b395d5ae
This commit is contained in:
Vincent St-Amour 2014-02-17 18:22:02 -05:00
parent 720544b95c
commit 1b78da2bf6
2 changed files with 25 additions and 2 deletions

View File

@ -75,7 +75,7 @@
[new-v v.opt])
;; do the impersonator check up front, to avoid doing it twice (length and op)
(if (impersonator? new-v)
(if #,(let ([one-sided #'(unsafe-fx< new-i (unsafe-vector*-length new-v))])
(if #,(let ([one-sided #'(unsafe-fx< new-i (unsafe-vector-length new-v))])
(if i-known-nonneg?
;; we know it's nonnegative, one-sided check
one-sided
@ -84,7 +84,7 @@
(op.unsafe new-v new-i new.opt ...)
#,safe-fallback) ; will error. to give the right error message
;; not an impersonator, can use unsafe-vector* ops
(if #,(let ([one-sided #'(unsafe-fx< new-i (unsafe-vector-length new-v))])
(if #,(let ([one-sided #'(unsafe-fx< new-i (unsafe-vector*-length new-v))])
(if i-known-nonneg?
one-sided
#`(and (unsafe-fx>= new-i 0)

View File

@ -0,0 +1,23 @@
#;#;
#<<END
END
#<<END
passed
END
#lang typed/racket
(: x (Vectorof Number))
(define x (make-vector 0 0))
(: y (Vectorof Float))
(define z (cast x '#()))
(define y (cast z (Vectorof Float)))
;; should error
(with-handlers ([exn:fail:contract?
(lambda (e)
(when (regexp-match "index is out of range for empty vector"
(exn-message e))
(display "passed\n")))])
(vector-set! y 1 3.0))