[Bro-Dev] switch/case type recognition

Matthias Vallentin vallentin at icir.org
Tue Sep 11 03:35:51 PDT 2018


Consider this snippet:

    function f(x: any)
      {
      switch (x)
        {
        case type any:
          print "any";
          break;
        case type vector of any:
          print "vector of any";
          break;
        }
      }

    event bro_init()
      {
      f(42);
      }

I would have imagined that the two cases are considered different types, 
but Bro doesn't think so:

    error in ./test.bro, lines 9-10: duplicate case label (case type vector of any:{ print anybreak })

Adding a type alias for either type doesn't change the error message.

I am aware that this is a somewhat pathological case, because 'case type 
any' is probably equivalent to the 'default' case.

    Matthias


More information about the bro-dev mailing list