diff --git a/frontends/p4/typeChecking/typeChecker.cpp b/frontends/p4/typeChecking/typeChecker.cpp index f7f555a0a49..ab77127d56a 100644 --- a/frontends/p4/typeChecking/typeChecker.cpp +++ b/frontends/p4/typeChecking/typeChecker.cpp @@ -1389,7 +1389,9 @@ const IR::Node* TypeInference::postorder(IR::Type_List* type) { const IR::Node* TypeInference::postorder(IR::Type_Tuple* type) { for (auto field : type->components) { auto fieldType = getTypeType(field); - if (fieldType->is() || fieldType->is()) { + if (auto spec = fieldType->to()) fieldType = spec->baseType; + if (fieldType->is() || fieldType->is() || + fieldType->is()) { typeError("%1%: not supported as a tuple field", field); return type; } diff --git a/testdata/p4_16_errors/issue3750-1.p4 b/testdata/p4_16_errors/issue3750-1.p4 new file mode 100644 index 00000000000..aad57280c1f --- /dev/null +++ b/testdata/p4_16_errors/issue3750-1.p4 @@ -0,0 +1,17 @@ +extern ct { + void apply(); +} + +extern E { + void apply(); +} + +void f(tuple t) +{ + t[0].apply(); +} + +void g(tuple>> t) +{ + t[0].apply(); +} \ No newline at end of file diff --git a/testdata/p4_16_errors_outputs/issue3750-1.p4 b/testdata/p4_16_errors_outputs/issue3750-1.p4 new file mode 100644 index 00000000000..ce4a2cb083e --- /dev/null +++ b/testdata/p4_16_errors_outputs/issue3750-1.p4 @@ -0,0 +1,14 @@ +extern ct { + void apply(); +} + +extern E { + void apply(); +} + +void f(tuple t) { + t[0].apply(); +} +void g(tuple>> t) { + t[0].apply(); +} diff --git a/testdata/p4_16_errors_outputs/issue3750-1.p4-stderr b/testdata/p4_16_errors_outputs/issue3750-1.p4-stderr new file mode 100644 index 00000000000..392126de4d5 --- /dev/null +++ b/testdata/p4_16_errors_outputs/issue3750-1.p4-stderr @@ -0,0 +1,6 @@ +issue3750-1.p4(9): [--Werror=type-error] error: ct: not supported as a tuple field +void f(tuple t) + ^^ +issue3750-1.p4(14): [--Werror=type-error] error: E>: not supported as a tuple field +void g(tuple>> t) + ^^^^^^^^^^