mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
Enabling record coercion for a table's &default attribute.
This commit is contained in:
parent
51f9cb2ac5
commit
83bd6584ee
2 changed files with 26 additions and 1 deletions
17
src/Val.cc
17
src/Val.cc
|
@ -2023,7 +2023,22 @@ Val* TableVal::Default(Val* index)
|
|||
return 0;
|
||||
|
||||
if ( ! def_val )
|
||||
def_val = def_attr->AttrExpr()->Eval(0);
|
||||
{
|
||||
BroType* ytype = Type()->YieldType();
|
||||
BroType* dtype = def_attr->AttrExpr()->Type();
|
||||
|
||||
if ( dtype->Tag() == TYPE_RECORD && ytype->Tag() == TYPE_RECORD &&
|
||||
! same_type(dtype, ytype) &&
|
||||
record_promotion_compatible(dtype->AsRecordType(), ytype->AsRecordType()) )
|
||||
{
|
||||
Expr* coerce = new RecordCoerceExpr(def_attr->AttrExpr(), ytype->AsRecordType());
|
||||
def_val = coerce->Eval(0);
|
||||
Unref(coerce);
|
||||
}
|
||||
|
||||
else
|
||||
def_val = def_attr->AttrExpr()->Eval(0);
|
||||
}
|
||||
|
||||
if ( ! def_val )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue