Open jaehyun1ee opened 3 weeks ago
For (1), I noticed that the spec mentions the following in section 6.8.1.
Actions can also be explicitly invoked using function call syntax, either from a control block or from another action. In this case, values for all action parameters must be supplied explicitly, including values for the directionless parameters. The directionless parameters in this case behave like in parameters.
So a directionless parameter passed to an action in a P4 program can be implicitly cast, because they are treated as direction in
.
But regarding (2), I found a lot of use cases in the p4c compiler test suite that expects implicit cast on function/method and constructor calls.
Would allowing implicit cast for directionless parameters, as well as in
parameters make sense?
There seems to be unspecified bits regarding implicit cast on function/method/(and action) calls.
Spec section 8.20. Method invocations and function calls mentions:
(1) How do we define implicit cast for action calls?
Strictly speaking, actions are neither a function nor a method, while they are quite similar constructs. But, the spec does not mention how casts should be inserted on action calls. Would it be safe to consider that implicit cast on action arguments behave the same as function/method arguments?
(2) Do we insert implicit cast for directionless arguments?
While the spec mentions that we only insert cast for direction
in
arguments, there exist some examples in the p4c compiler test suite where it expects to insert implicit casts for directionless arguments also.(a)
extern2.p4
Here, it is expected that the first directionless argument,
0
ofx.method
is implicitly casted tobit<16>
.(b)
action-bind.p4
Also here, the second directionless argument
0
for the default actiona
is expected to be implicitly cast tobit<32>
type.I wonder whether the p4c test suite is in a disagreement with the current spec, or the current spec is ambiguous.