Skip to content

Commit

Permalink
Disallow Type_Control as a tuple argument
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
  • Loading branch information
Mihai Budiu committed Dec 2, 2022
1 parent d0056fc commit 0d94633
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion frontends/p4/typeChecking/typeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,8 @@ const IR::Node* TypeInference::postorder(IR::Type_List* type) {

const IR::Node* TypeInference::postorder(IR::Type_Tuple* type) {
for (auto field : type->components) {
if (field->is<IR::IContainer>()) {
auto fieldType = getTypeType(field);
if (fieldType->is<IR::IContainer>() || fieldType->is<IR::Type_ArchBlock>()) {
typeError("%1%: not supported as a tuple field", field);
return type;
}
Expand Down
5 changes: 5 additions & 0 deletions testdata/p4_16_errors/issue3750.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
control ct();
void f(tuple<ct> t)
{
t[0].apply();
}
7 changes: 2 additions & 5 deletions testdata/p4_16_errors_outputs/issue3378.p4-stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
issue3378.p4(1): [--Werror=type-error] error: package f: not supported as a tuple field
package f();
^
issue3378.p4(2): [--Werror=type-error] error: Error while analyzing tuple<package f, package f>
issue3378.p4(2): [--Werror=type-error] error: f: not supported as a tuple field
package g(tuple<f,f> b);
^^^^^^^^^^
^
4 changes: 4 additions & 0 deletions testdata/p4_16_errors_outputs/issue3750.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
control ct();
void f(tuple<ct> t) {
t[0].apply();
}
3 changes: 3 additions & 0 deletions testdata/p4_16_errors_outputs/issue3750.p4-stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
issue3750.p4(2): [--Werror=type-error] error: ct: not supported as a tuple field
void f(tuple<ct> t)
^^

0 comments on commit 0d94633

Please sign in to comment.