Add checks to avoid improper negative values use.

This commit is contained in:
Jon Siwek 2013-09-17 16:42:48 -05:00
parent a3b963ad4e
commit a316878d01
12 changed files with 89 additions and 62 deletions

View file

@ -2670,6 +2670,16 @@ Val* RecordVal::LookupWithDefault(int field) const
return record_type->FieldDefault(field);
}
Val* RecordVal::Lookup(const char* field, bool with_default) const
{
int idx = record_type->FieldOffset(field);
if ( idx < 0 )
reporter->InternalError("missing record field: %s", field);
return with_default ? LookupWithDefault(idx) : Lookup(idx);
}
RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr, bool allow_orphaning) const
{
if ( ! record_promotion_compatible(t->AsRecordType(), Type()->AsRecordType()) )