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
In section 11.3.1. Instantiating objects with abstract methods, the spec mentions that:
The abstract methods can only use the supplied arguments or refer to values that are in the top-level scope.
When calling another method of the same instance the this keyword is used to indicate the current object instance.
However, tests issue2273-1.p4 and virtual3.p4 in testdata/p4_16_samples seem to violate this. The frontend accepts abstract method implementations referring to control-local variables or control parameters, when they should be rejected as per the spec.
FYI, there is a related p4-spec issue that has undergone ldwg discussion. It proposes to define the scope as, (i) the top level, (ii) supplied arguments to the method, and (iii) the object initializer block.
fruffy
added
the
p4-spec
Topics related to the P4 specification (https://github.com/p4lang/p4-spec/).
label
Jan 6, 2025
This would seem to be a typo in the spec -- it should be "in the enclosing scope" or "in the scope in which the extern instance declaration appears"
Note that if that was allowed, it would allow runtime values that are not arguments to come into an abstract methods (as far as I can see, the initializers added in p4lang/p4-spec#1355 can't be used to supply runtime values). That is a significant extension of the behavior allowed by the spec now.
That said, if I recall the Tofino's RegisterAction's use of abstract methods, I expect that they would make use of the ability to capture runtime values from the enclosing control block.
In section 11.3.1. Instantiating objects with abstract methods, the spec mentions that:
However, tests
issue2273-1.p4
andvirtual3.p4
intestdata/p4_16_samples
seem to violate this. The frontend accepts abstract method implementations referring to control-local variables or control parameters, when they should be rejected as per the spec.The text was updated successfully, but these errors were encountered: