Attr: Deprecate using &default and &optional together on record fields

If &default implies re-initialization of the field, using them together
doesn't make much sense.
This commit is contained in:
Arne Welzel 2025-07-27 15:56:00 +02:00
parent 23181e4811
commit 473723cc47
6 changed files with 43 additions and 1 deletions

View file

@ -0,0 +1,6 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
warning in <...>/optional-and-default-field.zeek, line 10: Remove in v8.1: Using &default and &optional together results in &default behavior
warning in <...>/optional-and-default-field.zeek, line 11: Remove in v8.1: Using &default and &optional together results in &default behavior
warning in <...>/optional-and-default-field.zeek, line 12: Remove in v8.1: Using &default and &optional together results in &default behavior
warning in <...>/optional-and-default-field.zeek, line 13: Remove in v8.1: Using &default and &optional together results in &default behavior
warning in <...>/optional-and-default-field.zeek, line 14: Remove in v8.1: Using &default and &optional together results in &default behavior

View file

@ -0,0 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[c=5, i=-5, v=[], r0=[], r1=[]]

View file

@ -0,0 +1,18 @@
# @TEST-DOC: Warn on record fields that have both, &optional and &default
#
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: btest-diff .stdout
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
type R: record { };
type X: record {
c: count &optional &default=5;
i: int &default=-5 &optional;
v: vector of string &optional &default=vector();
r0: R &optional &default=R();
r1: R &default=R() &optional;
};
global x = X();
print x;