sequences: Change bounds-check? to be generic on integer so that floating points can't index into sequences. Fixes #582.

db4
Doug Coleman 2012-07-31 08:36:34 -07:00
parent c26ad1eb10
commit 81f50d81eb
1 changed files with 5 additions and 3 deletions

View File

@ -50,11 +50,13 @@ M: sequence shorten 2dup length < [ set-length ] [ 2drop ] if ; inline
: push ( elt seq -- ) [ length ] [ set-nth ] bi ;
: bounds-check? ( n seq -- ? )
dupd length < [ 0 >= ] [ drop f ] if ; inline
ERROR: bounds-error index seq ;
GENERIC# bounds-check? 1 ( n seq -- ? )
M: integer bounds-check? ( n seq -- ? )
dupd length < [ 0 >= ] [ drop f ] if ; inline
: bounds-check ( n seq -- n seq )
2dup bounds-check? [ bounds-error ] unless ; inline