moose
moose copied to clipboard
Have input parameters required to be added before set
Motivation
When you set input parameters from code instead of from the input file, you can set parameters that don't actually exist or do anything. For example,
InputParameters
MyApp::validParams()
{
InputParameters params = MooseApp::validParams();
params.set<bool>("bogus") = false;
return params;
}
would not give any indication that the parameter bogus
doesn't exist. This is dangerous because users can set parameters expecting them to do something, while they actually don't.
Design
This would require a parameter to be "declared" via add*Param
before it is set
. Perhaps this could be achieved with a new Metadata
member _added
, which defaults to false
. The add*Param
methods would set this to true
, and set
would throw an error if false
.
Some parameters are "private", i.e., not to be seen/set in an input file, but there is a method addPrivateParam
that should be called for these.
Impact
More strict input parameter behavior. We could discover some parameters that were set but never added.
linked but not equal to #27556