justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

+i and -i are not bound; (sqrt -1) evaluates to NAN #530

Closed chebert closed 5 months ago

chebert commented 5 months ago

I'm trying it out in the browser.

> +i
Error: Unbound variable: +i 
> -i
Error: Unbound variable: -i 

> (sqrt -1)
-nan.0

> (complex? (sqrt -1))
#f

This works:

> +1i
1.0i

> (complex? +1i)
#t

+i and -i shouldn't be identifiers, but they are:

> (define +i +1i)
ok
> (define -i -1i)
ok
justinethier commented 5 months ago

Thanks for the report @chebert, this is great feedback! Let me see what it will take to get this fixed up...

justinethier commented 5 months ago

Fixed sqrt to properly return complex numbers. Next step is +i and -i...

justinethier commented 5 months ago

This has been fixed on the master branch. Unfortunately there were a few loose ends as complex numbers support is a fairly recent change.

Thanks again for the report!