mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Fix record constructors in table initializer indices. Addresses #660.
For an index expression list, ListExpr::InitVal() passed the TypeList to Expr::InitVal() for each expression element in the list instead of the type for that element. This made RecordConstructorExpr::InitVal() complain since it expects a RecordType and not a TypeList with a RecordType element as an argument. In most other cases, Expr::InitVal() worked because check_and_promote() "flattens" the list to a single type.
This commit is contained in:
parent
b867333c2e
commit
f6d5da423c
8 changed files with 350 additions and 2 deletions
|
@ -4893,9 +4893,16 @@ Val* ListExpr::InitVal(const BroType* t, Val* aggr) const
|
|||
{
|
||||
ListVal* v = new ListVal(TYPE_ANY);
|
||||
|
||||
const type_list* tl = type->AsTypeList()->Types();
|
||||
if ( exprs.length() != tl->length() )
|
||||
{
|
||||
Error("index mismatch", t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
loop_over_list(exprs, i)
|
||||
{
|
||||
Val* vi = exprs[i]->InitVal(t, 0);
|
||||
Val* vi = exprs[i]->InitVal((*tl)[i], 0);
|
||||
if ( ! vi )
|
||||
{
|
||||
Unref(v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue