missing void type


I wrote a script using functions that return void. The signatures are:

function check_unexpected_consume_produce(c: connection): void
function check_long_running_flow(c: connection): void

When I try to test the script, I get:

error in ./bro-scripts/bbn-flow-analyzer.bro, line 61: identifier not defined: void
error in ./bro-scripts/bbn-flow-analyzer.bro, line 84: identifier not defined: void
warning in ./bro-scripts/bbn-flow-analyzer.bro, line 116: expression value ignored (BBNFlowAnalyzer::check_unexpected_consume_produce(BBNFlowAnalyzer::c))
warning in ./bro-scripts/bbn-flow-analyzer.bro, line 117: expression value ignored (BBNFlowAnalyzer::check_long_running_flow(BBNFlowAnalyzer::c))

According to
void is a valid type. Am I missing something? I was originally planning
to write those functions as events instead, but if I understand
correctly, event execution can be delayed from when the event is
triggered. That would cause trouble for those functions, since they're
called from event connection_state_remove and they expect the connection
to still be valid.

I noticed this the other day in our documentation. I believe that void is only an internal type and isn't available in the script land as you discovered.

Just change your functions to this:
  function check_unexpected_consume_produce(c: connection)
  function check_long_running_flow(c: connection)

Problem solved. :slight_smile: