mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00

Mostly: Do not instantiate variables within for loops and allow reusing differently typed blanks which previously wasn't possible. This may be missing some corner-cases, but the added tests seem to work as expected and nothing else fell apart it seems.
54 lines
922 B
Text
54 lines
922 B
Text
# @TEST-DOC: Do not allow to reference the blank identifier.
|
|
|
|
# @TEST-EXEC-FAIL: zeek -b %INPUT
|
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
|
event zeek_init()
|
|
{
|
|
local vec = vector( "1", "2", "3" );
|
|
for ( _, v in vec )
|
|
print _;
|
|
}
|
|
|
|
@TEST-START-NEXT
|
|
event zeek_init()
|
|
{
|
|
local _ = vector( "1", "2", "3" );
|
|
print _;
|
|
}
|
|
|
|
@TEST-START-NEXT
|
|
# Ensure it does not work in a module, either.
|
|
module MyModule;
|
|
event zeek_init()
|
|
{
|
|
local _ = vector( "1", "2", "3" );
|
|
print _;
|
|
}
|
|
|
|
@TEST-START-NEXT
|
|
# Ensure _ can not referenced when it's a const in an export section.
|
|
# Adding the const _ isn't an error though.
|
|
module MyModule;
|
|
|
|
export {
|
|
const _: count = 1;
|
|
}
|
|
|
|
event zeek_init()
|
|
{
|
|
print MyModule::_;
|
|
}
|
|
|
|
@TEST-START-NEXT
|
|
# Ensure it does not work in a function.
|
|
module MyModule;
|
|
function helper()
|
|
{
|
|
local _ = vector( "1", "2", "3" );
|
|
print _;
|
|
}
|
|
|
|
event zeek_init()
|
|
{
|
|
helper();
|
|
}
|