Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have input parameters required to be added before set #27597

Open
joshuahansel opened this issue May 10, 2024 · 1 comment
Open

Have input parameters required to be added before set #27597

joshuahansel opened this issue May 10, 2024 · 1 comment
Labels
C: Framework T: task An enhancement to the software.

Comments

@joshuahansel
Copy link
Contributor

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.

@GiudGiud
Copy link
Contributor

GiudGiud commented May 15, 2024

linked but not equal to #27556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Framework T: task An enhancement to the software.
Projects
None yet
Development

No branches or pull requests

2 participants