zeek / spicy

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

unsupported operator: <Test::Msg>.bar_ instead of unknown field #1790

Open awelzel opened 1 month ago

awelzel commented 1 month ago

Very minor, but "unsupported operator" for a typo'ed field doesn't seem quite appropriate.

$ cat msg.spicy 
module Test;

type Msg = unit {
  var x: uint16;
  bar: uint16;

  on %done {
    self.x = self.bar_;
  }
};
$ spicyc -j  msg.spicy -o msg.hlto
[error] msg.spicy:8:14-8:22: unsupported operator: <Test::Msg>.bar_
[error] spicyc: aborting after errors
$ spicyc --version
spicyc v1.11.0-dev.251 (6581b185)
bbannier commented 1 month ago

Flagging this as regression since in v1.10 (prior to #1462) we used to report for this snippet

[error] msg.spicy:8:18: type does not have field 'bar_'
rsmmr commented 3 weeks ago

I think this needs a special-casing: if an AST ends up with anexpression::UnresolvedOperator node, check if its Kind::Member and if so, see if the reason why it couldn't be resolved is because there's no such field in the type; then report it as such instead of the generic error message. We already do similar special-casing for Kind::MemberCall to show candidate functions.