mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
parent
56325d1412
commit
006bef71b5
5 changed files with 70 additions and 0 deletions
|
@ -2170,6 +2170,9 @@ bool record_promotion_compatible(const RecordType* super_rec, const RecordType*
|
|||
if ( same_type(sub_field_type, super_field_type) )
|
||||
continue;
|
||||
|
||||
if ( BothArithmetic(sub_field_type->Tag(), super_field_type->Tag()) )
|
||||
continue;
|
||||
|
||||
if ( sub_field_type->Tag() != TYPE_RECORD )
|
||||
return false;
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/arithmetic-record-vec-fail.zeek, line 13 and int: type clash for field "a" ((coerce [$a=+1] to WithCount) and int)
|
||||
error in <...>/arithmetic-record-vec-fail.zeek, line 13 and int: type clash for field "a" ((coerce [$a=-2] to WithCount) and int)
|
||||
error in <...>/arithmetic-record-vec-fail.zeek, line 13 and double: type clash for field "a" ((coerce [$a=3.0] to WithCount) and double)
|
||||
error in <...>/arithmetic-record-vec-fail.zeek, line 16 and double: type clash for field "a" ((coerce [$a=1.0] to WithInt) and double)
|
||||
error in <...>/arithmetic-record-vec-fail.zeek, line 16 and double: type clash for field "a" ((coerce [$a=+2.0] to WithInt) and double)
|
||||
error in <...>/arithmetic-record-vec-fail.zeek, line 16 and double: type clash for field "a" ((coerce [$a=-3.0] to WithInt) and double)
|
|
@ -0,0 +1,7 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
[[a=1], [a=2], [a=3]]
|
||||
[[a=1], [a=2], [a=3]]
|
||||
[[a=1], [a=2], [a=3]]
|
||||
[[a=1.0], [a=2.0], [a=3.0]]
|
||||
[[a=1.0], [a=2.0], [a=3.0]]
|
||||
[[a=1.0], [a=2.0], [a=-3.0]]
|
16
testing/btest/language/arithmetic-record-vec-fail.zeek
Normal file
16
testing/btest/language/arithmetic-record-vec-fail.zeek
Normal file
|
@ -0,0 +1,16 @@
|
|||
# @TEST-EXEC-FAIL: zeek -b %INPUT 2>err
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff err
|
||||
|
||||
type WithCount: record {
|
||||
a: count;
|
||||
};
|
||||
|
||||
type WithInt: record {
|
||||
a: int;
|
||||
};
|
||||
|
||||
type CountRecVec: vector of WithCount;
|
||||
global vec_count_fail = CountRecVec([$a=+1], [$a=-2], [$a=3.0]);
|
||||
|
||||
type IntRecVec: vector of WithInt;
|
||||
global vec_int_fail = IntRecVec([$a=1.0], [$a=+2.0], [$a=-3.0]);
|
37
testing/btest/language/arithmetic-record-vec.zeek
Normal file
37
testing/btest/language/arithmetic-record-vec.zeek
Normal file
|
@ -0,0 +1,37 @@
|
|||
# @TEST-DOC: Ensures arithmetic type checking works when adding to vector; regression test for #4722
|
||||
#
|
||||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
type WithCount: record {
|
||||
a: count;
|
||||
};
|
||||
|
||||
type WithInt: record {
|
||||
a: int;
|
||||
};
|
||||
|
||||
type WithDouble: record {
|
||||
a: double;
|
||||
};
|
||||
|
||||
type CountRecVec: vector of WithCount;
|
||||
global vec_count = CountRecVec([$a=1], [$a=2], [$a=3]);
|
||||
|
||||
type IntRecVec: vector of WithInt;
|
||||
global vec_int = IntRecVec([$a=+1], [$a=+2], [$a=+3]);
|
||||
global vec_count_int = IntRecVec([$a=1], [$a=2], [$a=3]);
|
||||
|
||||
type DoubleRecVec: vector of WithDouble;
|
||||
global vec_double = DoubleRecVec([$a=1.0], [$a=2.0], [$a=3.0]);
|
||||
global vec_count_double = DoubleRecVec([$a=1], [$a=2], [$a=3]);
|
||||
global vec_int_double = DoubleRecVec([$a=+1], [$a=+2], [$a=-3]);
|
||||
|
||||
print vec_count;
|
||||
|
||||
print vec_int;
|
||||
print vec_count_int;
|
||||
|
||||
print vec_double;
|
||||
print vec_count_double;
|
||||
print vec_int_double;
|
Loading…
Add table
Add a link
Reference in a new issue