mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
Introduce special treatment for the blank identifier _
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.
This commit is contained in:
parent
7f7c77ab07
commit
46334f8b59
21 changed files with 318 additions and 20 deletions
|
@ -209,7 +209,7 @@ static void make_var(const IDPtr& id, TypePtr t, InitClass c, ExprPtr init,
|
|||
init = expand_op(cast_intrusive<ListExpr>(init), init_t);
|
||||
}
|
||||
|
||||
if ( id->GetType() )
|
||||
if ( id->GetType() && ! id->IsBlank() )
|
||||
{
|
||||
if ( id->IsRedefinable() || (! init && attr && ! IsFunc(id->GetType()->Tag())) )
|
||||
{
|
||||
|
@ -247,7 +247,7 @@ static void make_var(const IDPtr& id, TypePtr t, InitClass c, ExprPtr init,
|
|||
t = id->GetType();
|
||||
}
|
||||
|
||||
if ( id->GetType() && id->GetType()->Tag() != TYPE_ERROR )
|
||||
if ( id->GetType() && id->GetType()->Tag() != TYPE_ERROR && ! id->IsBlank() )
|
||||
{
|
||||
if ( dt != VAR_REDEF && (! init || ! do_init || (! t && ! (t = init_type(init)))) )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue