mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 04:58:21 +00:00
Merge remote-tracking branch 'origin/topic/vern/GH-3159.B'
* origin/topic/vern/GH-3159.B: Fix for nested "when" statements leading to confusion over scoping
This commit is contained in:
commit
f00dac544e
5 changed files with 30 additions and 15 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
6.1.0-dev.177 | 2023-07-06 11:34:38 +0200
|
||||||
|
|
||||||
|
* Fix for nested "when" statements leading to confusion over scoping (Vern Paxson, Corelight)
|
||||||
|
|
||||||
6.1.0-dev.175 | 2023-07-06 09:27:03 +0200
|
6.1.0-dev.175 | 2023-07-06 09:27:03 +0200
|
||||||
|
|
||||||
* Define early_shutdown lambda earlier in zeek-setup, avoids build failure with gperftools (Tim Wojtulewicz)
|
* Define early_shutdown lambda earlier in zeek-setup, avoids build failure with gperftools (Tim Wojtulewicz)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
6.1.0-dev.175
|
6.1.0-dev.177
|
||||||
|
|
14
src/Var.cc
14
src/Var.cc
|
@ -767,7 +767,6 @@ class OuterIDBindingFinder : public TraversalCallback
|
||||||
public:
|
public:
|
||||||
OuterIDBindingFinder(ScopePtr s) { scopes.emplace_back(s); }
|
OuterIDBindingFinder(ScopePtr s) { scopes.emplace_back(s); }
|
||||||
|
|
||||||
TraversalCode PreStmt(const Stmt*) override;
|
|
||||||
TraversalCode PreExpr(const Expr*) override;
|
TraversalCode PreExpr(const Expr*) override;
|
||||||
TraversalCode PostExpr(const Expr*) override;
|
TraversalCode PostExpr(const Expr*) override;
|
||||||
|
|
||||||
|
@ -775,19 +774,6 @@ public:
|
||||||
std::unordered_set<ID*> outer_id_references;
|
std::unordered_set<ID*> outer_id_references;
|
||||||
};
|
};
|
||||||
|
|
||||||
TraversalCode OuterIDBindingFinder::PreStmt(const Stmt* stmt)
|
|
||||||
{
|
|
||||||
if ( stmt->Tag() != STMT_WHEN )
|
|
||||||
return TC_CONTINUE;
|
|
||||||
|
|
||||||
auto ws = static_cast<const WhenStmt*>(stmt);
|
|
||||||
|
|
||||||
for ( auto& cl : ws->Info()->WhenExprLocals() )
|
|
||||||
outer_id_references.insert(const_cast<ID*>(cl.get()));
|
|
||||||
|
|
||||||
return TC_ABORTSTMT;
|
|
||||||
}
|
|
||||||
|
|
||||||
TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
|
||||||
{
|
{
|
||||||
if ( expr->Tag() == EXPR_LAMBDA )
|
if ( expr->Tag() == EXPR_LAMBDA )
|
||||||
|
|
3
testing/btest/Baseline/language.when-scope/out
Normal file
3
testing/btest/Baseline/language.when-scope/out
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
10.0.0.1
|
||||||
|
10.0.0.2
|
22
testing/btest/language/when-scope.zeek
Normal file
22
testing/btest/language/when-scope.zeek
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# @TEST-DOC: Check for regression of "when" capture confusion over outer scope
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: zeek -b %INPUT | sort >out
|
||||||
|
# @TEST-EXEC: btest-diff out
|
||||||
|
|
||||||
|
module Test;
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local myset = set(10.0.0.1, 10.0.0.2);
|
||||||
|
|
||||||
|
when [myset] (T)
|
||||||
|
{
|
||||||
|
for ( ip in myset )
|
||||||
|
{
|
||||||
|
when [ip] ( ip == ip )
|
||||||
|
{
|
||||||
|
print fmt("%s", ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue