mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/awelzel/defer-more-stuff'
* origin/topic/awelzel/defer-more-stuff: RecordType: Ensure &default fields are always re-initialized Attr: Deprecate using &default and &optional together on record fields RecordType: Allow deferring &default=vector(), set(), table() fields
This commit is contained in:
commit
10e7f14f78
12 changed files with 146 additions and 9 deletions
|
@ -0,0 +1,4 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
default, [v=[1, 2, 3, 100], r=[c=101]]
|
||||
after changing, [v=[1, 2, 3, 100, 4711], r=[c=42]]
|
||||
after delete, [v=[1, 2, 3, 102], r=[c=103]]
|
|
@ -1,2 +1,6 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
[a=<uninitialized>, b=<uninitialized>, c=<uninitialized>]
|
||||
[a={
|
||||
|
||||
}, b={
|
||||
|
||||
}, c=[]]
|
||||
|
|
|
@ -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=[]]
|
|
@ -1,3 +1,5 @@
|
|||
# @TEST-DOC: Test behavior of &default when deleting a record field and subsequently accessing it again.
|
||||
#
|
||||
# @TEST-EXEC: zeek -b %INPUT >output 2>&1
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
|
@ -14,3 +16,30 @@ delete test$b;
|
|||
delete test$c;
|
||||
|
||||
print test;
|
||||
|
||||
# @TEST-START-NEXT
|
||||
global c = 99;
|
||||
|
||||
# Helper function that's running as part of R's default construction.
|
||||
function seq(): count {
|
||||
++c;
|
||||
return c;
|
||||
}
|
||||
|
||||
type R: record {
|
||||
c: count &default=seq();
|
||||
};
|
||||
|
||||
type FooBar: record {
|
||||
v: vector of count &default=vector(1, 2, 3, seq());
|
||||
r: R &default=R();
|
||||
};
|
||||
|
||||
global test: FooBar;
|
||||
print "default", test;
|
||||
test$v += 4711;
|
||||
test$r$c = 42;
|
||||
print "after changing", test;
|
||||
delete test$v;
|
||||
delete test$r;
|
||||
print "after delete", test;
|
||||
|
|
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