Skip to content

Commit

Permalink
Fix type deduction for expressions when importing JSON
Browse files Browse the repository at this point in the history
A recent fix for a separate issue
(#888) exposed a separate
bug: the type of expressions for which the top-level operator was
"access_field" was not deduced properly (set to UNKNOWN instead of
DATA), which caused bmv2 to assert when building the Action object.

The same issue existed for "access_union_header", which is an operator
introduced more recently (and possibly not used by p4c yet).

Fixes #889
  • Loading branch information
antoninbas committed May 11, 2020
1 parent 7cc67a8 commit e2f46e4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/bm_sim/P4Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ P4Objects::build_expression(const Json::Value &json_expression,
} else if (op == "access_field") {
build_expression(json_left, expr);
expr->push_back_access_field(json_right.asInt());
*expr_type = ExprType::DATA;
} else if (op == "access_union_header") {
build_expression(json_left, expr);
expr->push_back_access_field(json_right.asInt());
*expr_type = ExprType::HEADER;
} else {
// special handling for unary + and -, we set the left operand to 0
if ((op == "+" || op == "-") && json_left.isNull())
Expand Down

0 comments on commit e2f46e4

Please sign in to comment.