mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Improve &default validation for global vars: exclude sets
This commit is contained in:
parent
4c066ca914
commit
4bf3c6ff22
3 changed files with 7 additions and 6 deletions
|
@ -288,9 +288,9 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
{
|
{
|
||||||
// &default is allowed for global tables, since it's used in initialization
|
// &default is allowed for global tables, since it's used in initialization
|
||||||
// of table fields. it's not allowed otherwise.
|
// of table fields. it's not allowed otherwise.
|
||||||
if ( global_var && ! type->IsSet() && type->Tag() != TYPE_TABLE )
|
if ( global_var && ! type->IsTable() )
|
||||||
{
|
{
|
||||||
Error("&default is not valid for global variables");
|
Error("&default is not valid for global variables except for tables");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 4: arithmetic mixed with non-arithmetic (set[string] and 0)
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 4: &default is not valid for global variables except for tables (&default=0)
|
||||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 4: &default value has inconsistent type (0 and set[string])
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 9: &default is not valid for global variables except for tables (&default=10)
|
||||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 9: &default is not valid for global variables (&default=10)
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 9: &default is not valid for global variables except for tables (&default=9)
|
||||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 9: &default is not valid for global variables (&default=9)
|
|
||||||
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 9: &optional is not valid for global variables (&default=9, &optional)
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 9: &optional is not valid for global variables (&default=9, &optional)
|
||||||
|
error in /home/jon/pro/zeek/zeek/testing/btest/.tmp/language.attr-default-global-set-error/attr-default-global-set-error.zeek, line 10: &default is not valid for global variables except for tables (&default=set())
|
||||||
|
|
|
@ -7,3 +7,4 @@ global d: count &default = 10
|
||||||
&optional
|
&optional
|
||||||
&log
|
&log
|
||||||
&add_func = function(): count { return 3; };
|
&add_func = function(): count { return 3; };
|
||||||
|
global myset: set[count] &default=set();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue