Skip to content

Commit

Permalink
Emit a reasonable error if someone uses type in place where expressio…
Browse files Browse the repository at this point in the history
…n is exprected
  • Loading branch information
vlstill committed Feb 12, 2024
1 parent 6cec6b4 commit 92edc33
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontends/p4/typeChecking/typeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3052,6 +3052,9 @@ const IR::Node *TypeInference::postorder(IR::PathExpression *expression) {
if (type != nullptr)
// may be nullptr because typechecking may have failed
type = cloneWithFreshTypeVariables(type->to<IR::Type_MethodBase>());
} else if (decl->is<IR::Type_Declaration>()) {
typeError("%1%: Type cannot be used here, expecting an expression.", expression);
return expression;
}

if (type == nullptr) {
Expand Down

0 comments on commit 92edc33

Please sign in to comment.