mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
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:
parent
23181e4811
commit
473723cc47
6 changed files with 43 additions and 1 deletions
|
@ -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
|
|
@ -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=[]]
|
18
testing/btest/language/optional-and-default-field.zeek
Normal file
18
testing/btest/language/optional-and-default-field.zeek
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue