nojanath / SublimeKSP

Fork of Nils Liberg's SublimeKSP plugin. See README for details.
GNU General Public License v3.0
84 stars 18 forks source link

Type casting issue: script runs in Kontakt 7 but fails to compile in Sublime KSP #456

Closed raptor-666 closed 4 weeks ago

raptor-666 commented 2 months ago

There is a discrepancy between the way a script is handled in the Sublime KSP package and in Kontakt 7's script editor. The provided script runs without issues in Kontakt 7 but throws an error during compilation in Sublime KSP.

Steps to Reproduce

  1. Create a new KSP script with the following code
    on init
    declare ~var := -1.0
    message(int(sgn(~var) * 1000.0))
    end on
  2. Compile the script.

Screenshot image

mkruselj commented 1 month ago

OK yeah this is a bit tricky, because sgn() (and signbit(), by extension) are overloaded in KSP to support integers and reals at once, but in sKSP they are made to return integer always, and this trips up the compiler...

mkruselj commented 1 month ago

I have a solution I think. abs() already has special handling for this, so it's a matter of appending these functions in that place, too 🙂

mkruselj commented 1 month ago

@raptor-666 Try pulling the master branch and check it out 🙂