mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
GH-1122: Improve error for global record initialization exceptions
This commit is contained in:
parent
ff0aa6b050
commit
cf06ade325
4 changed files with 41 additions and 2 deletions
17
src/Val.cc
17
src/Val.cc
|
@ -2886,7 +2886,22 @@ RecordVal::RecordVal(RecordTypePtr t, bool init_fields) : Val(std::move(t))
|
|||
{
|
||||
detail::Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||
detail::Attr* def_attr = a ? a->Find(detail::ATTR_DEFAULT).get() : nullptr;
|
||||
auto def = def_attr ? def_attr->GetExpr()->Eval(nullptr) : nullptr;
|
||||
ValPtr def;
|
||||
|
||||
if ( def_attr )
|
||||
try
|
||||
{
|
||||
def = def_attr->GetExpr()->Eval(nullptr);
|
||||
}
|
||||
catch ( InterpreterException& )
|
||||
{
|
||||
if ( run_state::is_parsing )
|
||||
parse_time_records[rt].pop_back();
|
||||
|
||||
delete AsNonConstRecord();
|
||||
throw;
|
||||
}
|
||||
|
||||
const auto& type = rt->FieldDecl(i)->type;
|
||||
|
||||
if ( def && type->Tag() == TYPE_RECORD &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue