mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

This marks every identifier used within an attribute as seeds. The scenario this avoids is functions referenced through attributes on unused tables or record types (&default, &expire_func, ...) being dinged as unused as that's rather confusing. Also adds test for the above and a light smoke test into language/ as it doesn't appear we had coverage here. Closes #3122
44 lines
1.1 KiB
Text
44 lines
1.1 KiB
Text
# @TEST-DOC: Usage analyzer marked lambdas and functions in attribute expressions of unused tables or record types as unused. That is a bit confusing. Regression test for #3122.
|
|
# @TEST-EXEC: zeek -b %INPUT
|
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
|
|
|
module MyModule;
|
|
|
|
## Lambda on table.
|
|
const ids1: table[count] of string = {
|
|
[1] = "One",
|
|
} &default=function(c: count): string {
|
|
return fmt("unknown-%d", c);
|
|
};
|
|
|
|
|
|
## External default function
|
|
function default_id(c: count): string {
|
|
return fmt("unknown-%d", c);
|
|
}
|
|
|
|
const ids2: table[count] of string = {
|
|
[1] = "One",
|
|
} &default=default_id;
|
|
|
|
|
|
## &default expression using function
|
|
function default_id2(): string {
|
|
return "";
|
|
}
|
|
|
|
const ids3: table[count] of string = {
|
|
[1] = "One",
|
|
} &default=default_id2() + "";
|
|
|
|
|
|
## &expire_func lambda using another function
|
|
function expire_f(t: table[count] of string, c: count): interval {
|
|
return 0.0sec;
|
|
}
|
|
|
|
const ids4: table[count] of string = {
|
|
[1] = "One",
|
|
} &expire_func=function(t: table[count] of string, c: count): interval {
|
|
return expire_f(t, c);
|
|
};
|