mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
GH-1628: Return an error for duplicate record field names
This commit is contained in:
parent
d57ad3e405
commit
b41a4bf06d
5 changed files with 28 additions and 3 deletions
12
src/Type.cc
12
src/Type.cc
|
@ -1039,6 +1039,16 @@ void RecordType::AddField(unsigned int field, const TypeDecl* td)
|
|||
ASSERT(field == field_inits.size());
|
||||
ASSERT(field == managed_fields.size());
|
||||
|
||||
if ( field_ids.count(td->id) != 0 )
|
||||
{
|
||||
reporter->Error("Duplicate field '%s' found in record definition\n", td->id);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
field_ids.insert(std::string(td->id));
|
||||
}
|
||||
|
||||
managed_fields.push_back(ZVal::IsManagedType(td->type));
|
||||
|
||||
auto init = new FieldInit();
|
||||
|
@ -1106,7 +1116,7 @@ void RecordType::AddField(unsigned int field, const TypeDecl* td)
|
|||
|
||||
bool RecordType::HasField(const char* field) const
|
||||
{
|
||||
return FieldOffset(field) >= 0;
|
||||
return field_ids.count(field) != 0;
|
||||
}
|
||||
|
||||
ValPtr RecordType::FieldDefault(int field) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue