Ok, just triggered the same bug. Same line of code, same vars... Also on the web version if that makes any difference.
Tought me to look up how to save this game :)
Interesting, I know I’m quite late but any idea what item you had selected at the time?