You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here, we do not supply any argument to the instantiation of package main, so the default values of c1 and c2 take place.
However, c1 implies H = a_t and M = a_t while c2 implies that H = b_t and M = b_t.
So in this case, the compiler shouldn't be able to infer the correct type argument for the don't care types (_) in P<_, _>.
Also, if we change the program as follows, where we instantiate P() main; instead of P<_, _>() main;,
then the compiler rejects the program (as expected) saying:
default-package-argument-reduced.p4(11): [--Werror=type-error] error: main: could not infer a type for variable H
P() main;
^^^^
default-package-argument-reduced.p4(9)
package P<H, M>(C<H, M> c1 = foo(), C<H, M> c2 = bar());
I believe it suggests some possibility that the frontend overlooks some case when inferring concrete types for don't care types _.
The text was updated successfully, but these errors were encountered:
fruffy
added
bug
This behavior is unintended and should be fixed.
p4-spec
Topics related to the P4 specification (https://github.com/p4lang/p4-spec/).
labels
Dec 2, 2024
The p4c frontend regards the following program as valid, when it is actually not.
Here, we do not supply any argument to the instantiation of package
main
, so the default values ofc1
andc2
take place.However,
c1
impliesH = a_t
andM = a_t
whilec2
implies thatH = b_t
andM = b_t
.So in this case, the compiler shouldn't be able to infer the correct type argument for the don't care types (
_
) inP<_, _>
.Also, if we change the program as follows, where we instantiate
P() main;
instead ofP<_, _>() main;
,then the compiler rejects the program (as expected) saying:
I believe it suggests some possibility that the frontend overlooks some case when inferring concrete types for don't care types
_
.The text was updated successfully, but these errors were encountered: