-
Notifications
You must be signed in to change notification settings - Fork 47
Description
The function below enters an "endless" loop when compiled.
(defun foo () (dotimes (i 10.0) (print i)))
This is because the dotimes value is declared as integer https://github.com/euslisp/EusLisp/blob/master/lisp/l/common.l#L150 , so in the compiled code the value 10.0 gets interpreted as a much larger number instead (pointer address?). The declaration is ignored in non-compiled code.
Similar problems occur in nstring-downcase
and nstring-upcase
(https://github.com/euslisp/EusLisp/blob/master/lisp/l/string.l#L93-L107), where :start and :end are declared as integers but can be any value passed by the user.
eus$ (let ((str "HELLO")) (nstring-downcase str :start 1))
;; "Hello"
eus$ (let ((str "HELLO")) (nstring-downcase str :start 1.0))
;; "HELLO"
eus$ (let ((str "HELLO")) (nstring-downcase str :start (make-coords)))
;; "HELLO"
It should be fairly easy to remove the declaration and/or add some checks in the nstring-downcase
and nstring-upcase
functions, but the dotimes case seems more complicated because it should remain highly optimized and backwards compatible in non-compiled code...
Also similar to #265