Type/RecordType: Make table returned by GetRecordFieldsVal() ordered

Seems only reasonable to provide that guarantee as pointed out in #4674.
This commit is contained in:
Arne Welzel 2025-07-22 15:36:34 +02:00
parent db018253fe
commit 9f3a3b423f
9 changed files with 54 additions and 43 deletions

View file

@ -1213,7 +1213,12 @@ static string container_type_name(const Type* ft) {
TableValPtr RecordType::GetRecordFieldsVal(const RecordVal* rv) const {
static auto record_field = id::find_type<RecordType>("record_field");
static auto record_field_table = id::find_type<TableType>("record_field_table");
auto rval = make_intrusive<TableVal>(record_field_table);
auto attrs = zeek::make_intrusive<detail::Attributes>(record_field_table,
/*in_record=*/false,
/*is_global=*/false);
attrs->AddAttr(make_intrusive<detail::Attr>(detail::ATTR_ORDERED));
auto rval = make_intrusive<TableVal>(record_field_table, std::move(attrs));
for ( int i = 0; i < NumFields(); ++i ) {
const auto& ft = GetFieldType(i);