Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotimes don't exit for float arguments when compiled #466

Open
Affonso-Gui opened this issue Sep 20, 2021 · 0 comments
Open

dotimes don't exit for float arguments when compiled #466

Affonso-Gui opened this issue Sep 20, 2021 · 0 comments

Comments

@Affonso-Gui
Copy link
Member

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

@Affonso-Gui Affonso-Gui mentioned this issue Sep 21, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant