Fixing a bug with nested record ctors.

If a record field was initialized with another record ctor, there was
no record type coercion in place in case of a type mismatch.
This commit is contained in:
Robin Sommer 2011-03-17 17:19:46 -07:00
parent af3267acc3
commit 7526058071

View file

@ -3316,7 +3316,15 @@ Val* RecordConstructorExpr::InitVal(const BroType* t, Val* aggr) const
break; break;
} }
else if ( ar_t->FieldType(t_i)->Tag() == TYPE_RECORD
&& ! same_type(ar_t->FieldType(t_i), rv->Lookup(i)->Type()) )
{
Expr* rhs = new ConstExpr(rv->Lookup(i)->Ref());
Expr* e = new RecordCoerceExpr(rhs, ar_t->FieldType(t_i)->AsRecordType());
ar->Assign(t_i, e->Eval(0));
break;
}
ar->Assign(t_i, rv->Lookup(i)->Ref()); ar->Assign(t_i, rv->Lookup(i)->Ref());
} }