mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
tests added for new capture-by-reference closure semantics & errors
This commit is contained in:
parent
4884b191e8
commit
35421b07f1
8 changed files with 503 additions and 0 deletions
21
testing/btest/language/closure-binding-errors.zeek
Normal file
21
testing/btest/language/closure-binding-errors.zeek
Normal file
|
@ -0,0 +1,21 @@
|
|||
# @TEST-EXEC-FAIL: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||
|
||||
global c: string;
|
||||
type t: addr;
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
local a = 3;
|
||||
local b = "hi there";
|
||||
|
||||
local f1 = function[a]() { print "no a!"; };
|
||||
local f2 = function[a2](a2: addr) { print a2; };
|
||||
local f3 = function[a]() { print b; };
|
||||
local f4 = function[a, b]() { print b; };
|
||||
local f5 = function[b, b]() { print b; };
|
||||
local f6 = function() { print c; }; # should be okay
|
||||
local f7 = function[c]() { print c; };
|
||||
local f8 = function[t]() { local t2: t; };
|
||||
local f9 = function[a]() { local a = 4; }; # error due to shadowing
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue