if (expr == null) {
return field;
} else if (expr instanceof NothingExpr) {
return field;
} else if (expr instanceof RecordExpr) {
RecordExpr record = (RecordExpr)expr;
List<Pair<String, Expr>> fields = new ArrayList<Pair<String, Expr>>(record.getFields());
fields.add(new Pair<String, Expr>(Name.getTupleField(fields.size()), field));
return Expr.record(record.getPosition(), fields);
} else {
return Expr.record(expr, field);
}
}