Thanks for reporting this! This should be fixed in 0.17.41/0.18.8. Basically, this was another case of a local variable (rather: a local function) that escaped into global space …
Fun fact: While this particular error only occurs in 0.18.7, a similar crash in another place (not yet reported) was just waiting to happen in 0.17.40 for the same reason: a typo when trying to call that same function producing debugging output. Because of those typos (different spellings of the function name), the script stumbled over undeclared variables/functions, so it bailed out.
I've included some quality-assurance code provided by eradicator that lets the game crash when something like this occurs. Without that code, the game wouldn't crash. However, using undeclared variables/functions is likely to break things in other places. For example, if an undeclared -- thus empty -- variable is used in the check condition of an "if … then do …" test, some code may never be reached, so the bio cannon might try to shoot at something even if there is no spawner, or planted trees might never grow. This would be much harder to debug than an immediate crash, so these crashes are a good thing even if they cause some grief to players when they occur.
While I try my best to test as much as possible before uploading, BI alone is too big for just one guy to test everything for every condition. It's even worse when other mods are used together with BI and recipes, technology unlocks etc. are changed, or if some settings have been turned on/off (which happened before the last release: there was no bio cannon in my test game, so eradicator's code wouldn't trigger).
Conclusion: As I've included eradicator's QA code just recently, there's a good chance that even more errors which have previously gone unnoticed will result in a crash. Over time, most (or even all) of them should be revealed, so these annoying crashes will improve BI in the long run. :-)