zeek / spicy

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

Surprising "auto cannot be used for variable declaration" #1792

Open awelzel opened 1 month ago

awelzel commented 1 month ago

Slight duplicate of #1790, but I was surprised by the "type 'auto' cannot be used for variable declaration" - is that needed/useful?

$ cat strange.spicy 
module Test;

type T = unit() {
  x: uint8;
};

public type U = unit() {
  len: uint32;

  ts: T[] &size=self.len {
    for ( e in self.tss )  # typoed and should just be $$
      print e.x;
  }
};
$ spicyc -j strange.spicy -o /tmp/x.hlto
[error] strange.spicy:11:5-12:16: type 'auto' cannot be used for variable declaration
[error] strange.spicy:11:16-11:23: unsupported operator: <Test::U>.tss
[error] strange.spicy:12:13-12:15: unsupported operator: <auto>.x
[error] spicyc: aborting after errors
rsmmr commented 1 month ago

It's a prioritization issue in the output: the right error is the 2nd (modulo #1790), the 1st and 3rd are follow-ups that would better be suppressed (which is possible, just needs a bit of additional logic in the validator).

bbannier commented 1 month ago

Similar to #1790, marking this as a regression since before #1462 we would have reported

[error] foo.spicy:11:19-11:26: type does not have field 'tss'
[error] foo.spicy:12:19-12:19: unknown ID 'e'
[error] spicyc: aborting after errors