Merge remote-tracking branch 'origin/topic/jsiwek/record-coerce-orphans'

* origin/topic/jsiwek/record-coerce-orphans:
  Add an error for record coercions that would orphan a field.

Closes #936.
This commit is contained in:
Robin Sommer 2013-01-25 13:53:12 -08:00
commit f6c8995fd2
8 changed files with 36 additions and 13 deletions

View file

@ -3921,8 +3921,11 @@ RecordCoerceExpr::RecordCoerceExpr(Expr* op, RecordType* r)
{
int t_i = t_r->FieldOffset(sub_r->FieldName(i));
if ( t_i < 0 )
// Orphane field in rhs, that's ok.
continue;
{
ExprError(fmt("orphaned field \"%s\" in record coercion",
sub_r->FieldName(i)));
break;
}
BroType* sub_t_i = sub_r->FieldType(i);
BroType* sup_t_i = t_r->FieldType(t_i);