objecthub / swift-lispkit

Interpreter framework for Lisp-based extension and scripting languages on macOS and iOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.
https://lisppad.app
Apache License 2.0
392 stars 16 forks source link

`(lispkit math)` truncation procedures do not guard against zero divisor #16

Closed csutter closed 2 years ago

csutter commented 2 years ago

Unlike division, implementations of the truncation procedures in (lispkit math) (such as truncate-remainder) do not guard against the divisor (n2) being zero, and this causes LispPad to crash when the procedure is evaluated.

How to reproduce:

➤ (/ 2 0) ; ⚠️ 〚eval error〛 division by zero
➤ (truncate-remainder 2 0) ; app crashes

Happy to attempt a PR but I reckon my Swift is good enough to find the problem, but not good enough to come up with an elegant solution!

PS: Thank you so much for building software that has brought me so much joy ❤️ Never thought I'd be writing Lisp on the couch on my iPad!

objecthub commented 2 years ago

Thanks a lot for the bug report! This is indeed pretty bad. Have just fixed the "division by zero" issues. It will take a few more weeks before this change is available via LispPad.

Great to hear you like LispPad!

objecthub commented 2 years ago

The new releases of LispPad and LispPad Go fix this problem finally. Thanks for reporting the bug!