zeek / spicy

C++ parser generator for dissecting protocols & files.
https://docs.zeek.org/projects/spicy
Other
243 stars 37 forks source link

Trailing `if` on unit `switch` is ignored #1759

Closed bbannier closed 2 months ago

bbannier commented 2 months ago

We allow code with a unit switch with a trailing if, e.g.,

public type X = unit {
    switch {
        -> a: b"A";
        -> b: b"B";
        -> c: b"C";
    } if(False) ;
};

The condition is however silently ignored; for above False I would expect X to consume no data but it does

$ printf 'A' | spicy-dump -d foo.spicy
foo::X {
  a: A
}

We should either interpret such conditions correctly or reject them outright.