mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
Change record field anonymous functions to use lambda expressions
There was an alternate syntax to assign anonymous functions to record fields that was never migrated to use the new lambda expression machinery (and so didn't allow referencing variables in outer scope): type myrec: record { foo: function(a: string); }; local o = "o"; local mr = myrec($foo(a: string) = { print a + o; });
This commit is contained in:
parent
66156b4eee
commit
f032885085
5 changed files with 40 additions and 35 deletions
10
src/Var.cc
10
src/Var.cc
|
@ -476,16 +476,6 @@ void end_func(IntrusivePtr<Stmt> body)
|
|||
{
|
||||
auto ingredients = std::make_unique<function_ingredients>(pop_scope(), std::move(body));
|
||||
|
||||
if ( streq(ingredients->id->Name(), "anonymous-function") )
|
||||
{
|
||||
OuterIDBindingFinder cb(ingredients->scope.get());
|
||||
ingredients->body->Traverse(&cb);
|
||||
|
||||
for ( size_t i = 0; i < cb.outer_id_references.size(); ++i )
|
||||
cb.outer_id_references[i]->Error(
|
||||
"referencing outer function IDs not supported");
|
||||
}
|
||||
|
||||
if ( ingredients->id->HasVal() )
|
||||
ingredients->id->ID_Val()->AsFunc()->AddBody(
|
||||
ingredients->body,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue