Freezing IDE in if/elif blocks

If you have a largish if/elif block, trying to edit the code causes the IDE to freeze.

In this project here :
https://anvil.works/build#clone:VUSE6DI3TL5YFBJL=H42KRQJDJ3KNVUDCUMKSFGRJ

Go to any of the elif blocks and try to insert a line. As soon as you start typing the IDE will freeze and you will get a JS warning about a long running script. Sometimes if you wait enough times it will finish, but irrespective you will need to refresh the browser tab to continue editing.

It starts to slow down noticeably with 10 elifs, significantly with 12 and it breaks entirely at above 14ish.

I have fixed my issue by just using multiple if without the elif, but that might not suit everyone.

Thanks for spotting this! We’ll get it sorted ASAP.

[Moved to bug reports]

This is now fixed. Feel free to create if/elif blocks as long as you like :slight_smile:

Just for general interest, our parser was accidentally O(n!) in the number of elifs. Honestly, I’m impressed you made it to 12 before your browser gave up entirely! The parsing algorithm is now altogether less silly. Enjoy.

3 Likes

Not sure if my 128G of RAM helped any there or not :slight_smile:

Thanks for fixing.