Skip to content

Commit

Permalink
[Unity] Improved error message in ExprMutator::ReEmitBinding (#16307)
Browse files Browse the repository at this point in the history
Prior to this commit, an error message would occur in
`ExprMutator::ReEmitBinding` if the struct info is missing from the
generated value.  However, because this error was generated from
inside `GetStructInfo`, it didn't include sufficient context for
debugging.  This commit checks the struct info explicitly, and
includes the context of the updated variable in the error message.
  • Loading branch information
Lunderberg authored Jan 8, 2024
1 parent ef2a913 commit b22aa0f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/relax/ir/expr_functor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,15 @@ void ExprMutator::ReEmitBinding(const VarBindingNode* binding, Expr new_value) {
return;
}

Var temp = WithStructInfo(new_var, GetStructInfo(new_value));
auto new_sinfo = new_value->struct_info_.as<StructInfo>();

ICHECK(new_sinfo)
<< "InternalError: "
<< "In binding of variable " << binding->var << ", the value " << new_value
<< " does not have StructInfo. "
<< "This typically occurs when ReEmitBinding is called without first calling Normalize.";

Var temp = WithStructInfo(new_var, new_sinfo.value());
if (!temp.same_as(new_var)) {
new_var = temp;
}
Expand Down

0 comments on commit b22aa0f

Please sign in to comment.