| 606 | } |
| 607 | |
| 608 | static Status CheckIndex(int index, const DataType& type) { |
| 609 | if (!ValidParentType(type)) { |
| 610 | return Status::TypeError("struct_field: cannot subscript field of type ", type); |
| 611 | } else if (index < 0 || index >= type.num_fields()) { |
| 612 | return Status::Invalid("struct_field: out-of-bounds field reference to field ", |
| 613 | index, " in type ", type, " with ", type.num_fields(), |
| 614 | " fields"); |
| 615 | } |
| 616 | return Status::OK(); |
| 617 | } |
| 618 | |
| 619 | static bool ValidParentType(const DataType& type) { |
| 620 | return type.id() == Type::STRUCT || type.id() == Type::DENSE_UNION || |
nothing calls this directly
no test coverage detected