bug fix for empty table constructors with &default attributes (plus a typo)

This commit is contained in:
Vern Paxson 2022-03-31 19:28:23 -07:00
parent aa8f11fa17
commit 18fe9d84f6
2 changed files with 9 additions and 1 deletions

View file

@ -2407,6 +2407,14 @@ void TableVal::InitDefaultFunc(detail::Frame* f)
return;
const auto& ytype = GetType()->Yield();
if ( ! ytype )
// This happens for empty table() constructors. Don't
// instantiate a default value at this point, as we'll
// first need to type-check the attribute when the value
// is finally used.
return;
const auto& dtype = def_attr->GetExpr()->GetType();
if ( dtype->Tag() == TYPE_RECORD && ytype->Tag() == TYPE_RECORD && ! same_type(dtype, ytype) &&