Improve type inference for vector-of-enum constructor

This commit is contained in:
Jon Siwek 2019-07-25 13:49:41 -07:00
parent 9698d8d7cc
commit 70aa886806
5 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,2 @@
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.vector-of-enum-mismatch/vector-of-enum-mismatch.zeek, line 7 and /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.vector-of-enum-mismatch/vector-of-enum-mismatch.zeek, line 8: incompatible enum types: 'color' and 'number' (enum and enum)
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.vector-of-enum-mismatch/vector-of-enum-mismatch.zeek, line 9: inconsistent types in list

View file

@ -0,0 +1 @@
vector of enum, [Red, Green, Blue]

View file

@ -0,0 +1,9 @@
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
# Type inference for vector constructor comprised of disparate enum types
# should raise an error message about the types being incompatible.
type color: enum { Red, Green, Blue };
type number: enum { One, Two, Three, Four};
global v = vector(Red, Four, Blue);

View file

@ -0,0 +1,9 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# Type inference for vector constructor comprised of enums should work fine
# (previously the internal merge_types code did not handle enums).
type color: enum { Red, Green, Blue };
global v = vector(Red, Green, Blue);
print type_name(v), v;