diff --git a/src/Val.cc b/src/Val.cc index e2cc1e58e5..3d3290a200 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -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) && diff --git a/src/Val.h b/src/Val.h index 3e578a52d7..afa77c8818 100644 --- a/src/Val.h +++ b/src/Val.h @@ -935,7 +935,7 @@ public: void InitTimer(double delay); void DoExpire(double t); - // If the &default attribute is not a function, or the functon has + // If the &default attribute is not a function, or the function has // already been initialized, this does nothing. Otherwise, evaluates // the function in the frame allowing it to capture its closure. void InitDefaultFunc(detail::Frame* f);