Tame error reporting and abort() for undefined types

The script added as a test case reports the following messages *and*
dumps a core file. Printing the first error and a normal failure exit
seems sufficient. IMO triggering an abort() due to user scripting issues
is not something that Zeek should do

    $ zeek ./identifier-not-defined-error.zeek
    error in ./identifier-not-defined-error.zeek, line 10: identifier not defined: MyEnu
    error in ./identifier-not-defined-error.zeek, line 10 and error: &default value has inconsistent type (M::MY_ENUM_A and error)
    internal error in ./identifier-not-defined-error.zeek, line 11: type inconsistency in ZVal constructor
    Aborted (core dumped)

Change is to skip certain checks when an error type is propagated.
This commit is contained in:
Arne Welzel 2023-01-26 14:40:15 +01:00
parent 9a96e3b52a
commit 25ee288a76
4 changed files with 20 additions and 3 deletions

View file

@ -1088,7 +1088,7 @@ void RecordType::AddField(unsigned int field, const TypeDecl* td)
auto def_attr = a ? a->Find(detail::ATTR_DEFAULT) : nullptr;
auto def_expr = def_attr ? def_attr->GetExpr() : nullptr;
if ( def_expr )
if ( def_expr && ! IsErrorType(type->Tag()) )
{
if ( type->Tag() == TYPE_RECORD && def_expr->GetType()->Tag() == TYPE_RECORD &&
! same_type(def_expr->GetType(), type) )