Disallow default parameters in parser/control type declarations#5687
Open
Sanketjadhav31 wants to merge 4 commits into
Open
Disallow default parameters in parser/control type declarations#5687Sanketjadhav31 wants to merge 4 commits into
Sanketjadhav31 wants to merge 4 commits into
Conversation
Signed-off-by: Sanketjadhav31 <sj546400@gmail.com>
Signed-off-by: Sanketjadhav31 <sj546400@gmail.com>
Signed-off-by: Sanketjadhav31 <sj546400@gmail.com>
Signed-off-by: Sanketjadhav31 <sj546400@gmail.com>
Contributor
|
This doesn't really "disallow" control/parser types with default args as such -- it flags an error if you ever try to call something (a package, generally, as only packages can have control/parser types as args) that uses control/parser type with a default arg. You can still declare such types, and declare packages that take them as args, as long as you never try to instantiate said package. This may be good enough -- actually trying to flag an error when the control/parser type is created would also flag errors for simple controls and parsers that have default args (which should be ok). @fruffy @jafingerhut any opinion as to whether this is an acceptable approach? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5685
Summary
Disallow default parameter values in parser and control type declarations.
The frontend now reports a type error when a parser or control type declaration contains an apply parameter with a default value.
The existing control type test is moved from
p4_16_samplestop4_16_errors, and a parser type regression test is added. Ordinary parser and control declarations with default parameters remain valid.Tests
ctest -R "err.*default-control-argument" --output-on-failurectest -R "err.*issue5685-parser-default" --output-on-failurectest -R "p4.*issue1333" --output-on-failuregit diff HEAD --check