Skip to content

Commit f92f354

Browse files
committed
Improve unevaluated hideResult warning message
- Change the warning for a hideResult annotation that could not be evaluated to a real error message and include more information.
1 parent 0e36d4c commit f92f354

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

.openmodelica.aspell

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ convertPackageToLibrary
8080
noneFromVersion
8181
allowNonStandardModelica
8282
reinitInAlgorithms
83+
hideResult

OMCompiler/Compiler/SimCode/SimCodeUtil.mo

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10084,7 +10084,7 @@ algorithm
1008410084
commentStr = unparseCommentOptionNoAnnotationNoQuote(comment);
1008510085
(unit, displayUnit) = extractVarUnit(dae_var_attr);
1008610086
isProtected = BackendVariable.isProtected(dlowVar);
10087-
hideResult = getHideResult(hideResultExp);
10087+
hideResult = getHideResult(hideResultExp, cr, source);
1008810088
initVal = dlowVar.bindExp;
1008910089
isFixed = BackendVariable.varFixed(dlowVar);
1009010090
type_ = tp;
@@ -10120,7 +10120,7 @@ algorithm
1012010120
commentStr = unparseCommentOptionNoAnnotationNoQuote(comment);
1012110121
(unit, displayUnit) = extractVarUnit(dae_var_attr);
1012210122
isProtected = BackendVariable.isProtected(dlowVar);
10123-
hideResult = getHideResult(hideResultExp);
10123+
hideResult = getHideResult(hideResultExp, cr, source);
1012410124
(minValue, maxValue) = getMinMaxValues(dlowVar);
1012510125
initVal = getStartValue(dlowVar);
1012610126
nomVal = getNominalValue(dlowVar);
@@ -10166,7 +10166,7 @@ algorithm
1016610166
commentStr = unparseCommentOptionNoAnnotationNoQuote(comment);
1016710167
(unit, displayUnit) = extractVarUnit(dae_var_attr);
1016810168
isProtected = BackendVariable.isProtected(dlowVar);
10169-
hideResult = getHideResult(hideResultExp);
10169+
hideResult = getHideResult(hideResultExp, cr, source);
1017010170
(minValue, maxValue) = getMinMaxValues(dlowVar);
1017110171
initVal = getStartValue(dlowVar);
1017210172
nomVal = getNominalValue(dlowVar);
@@ -10213,7 +10213,7 @@ algorithm
1021310213
commentStr = unparseCommentOptionNoAnnotationNoQuote(comment);
1021410214
(unit, displayUnit) = extractVarUnit(dae_var_attr);
1021510215
isProtected = BackendVariable.isProtected(dlowVar);
10216-
hideResult = getHideResult(hideResultExp);
10216+
hideResult = getHideResult(hideResultExp, cr, source);
1021710217
(minValue, maxValue) = getMinMaxValues(dlowVar);
1021810218
initVal = getStartValue(dlowVar);
1021910219
nomVal = getNominalValue(dlowVar);
@@ -12218,6 +12218,8 @@ end eqSystemWCET;
1221812218
protected function getHideResult
1221912219
"Returns the value of the hideResult attribute."
1222012220
input Option<DAE.Exp> hideResultExp;
12221+
input DAE.ComponentRef name;
12222+
input DAE.ElementSource source;
1222112223
output Option<Boolean> hideResult;
1222212224
algorithm
1222312225
hideResult := match(hideResultExp)
@@ -12226,7 +12228,8 @@ algorithm
1222612228
case(SOME(DAE.BCONST(true))) then SOME(true);
1222712229
else
1222812230
equation
12229-
Error.addCompilerWarning("The hideResult annotation could not be evaluated, probably due to missing annotation(Evaluate=true). It is removed.");
12231+
Error.addSourceMessage(Error.HIDE_RESULT_NOT_EVALUATED,
12232+
{ComponentReference.printComponentRefStr(name)}, ElementSource.getInfo(source));
1223012233
then NONE();
1223112234
end match;
1223212235
end getHideResult;

OMCompiler/Compiler/Util/Error.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,8 @@ public constant ErrorTypes.Message NOTIFY_PKG_ALREADY_INSTALLED = ErrorTypes.MES
11371137
Gettext.gettext("%s %s is already installed, skipping."));
11381138
public constant ErrorTypes.Message REINIT_IN_ALGORITHM = ErrorTypes.MESSAGE(618, ErrorTypes.TRANSLATION(), ErrorTypes.ERROR(),
11391139
Gettext.gettext("Operator reinit may not be used in an algorithm section (use translation flag --allowNonStandardModelica=reinitInAlgorithms to ignore)."));
1140+
public constant ErrorTypes.Message HIDE_RESULT_NOT_EVALUATED = ErrorTypes.MESSAGE(619, ErrorTypes.TRANSLATION(), ErrorTypes.WARNING(),
1141+
Gettext.gettext("Ignoring the hideResult annotation on '%s' which could not be evaluated, probably due to missing annotation(Evaluate=true)."));
11401142

11411143
public constant ErrorTypes.Message MATCH_SHADOWING = ErrorTypes.MESSAGE(5001, ErrorTypes.TRANSLATION(), ErrorTypes.ERROR(),
11421144
Gettext.gettext("Local variable '%s' shadows another variable."));

testsuite/simulation/modelica/parameters/hideResult.mos

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ val(c.b.a, 0.0); getErrorString();
8080
// ""
8181
// record SimulationResult
8282
// resultFile = "hideResult_res.mat",
83-
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'hideResult', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
83+
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'hideResult', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
8484
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
8585
// LOG_SUCCESS | info | The simulation finished successfully.
8686
// "
@@ -93,20 +93,20 @@ val(c.b.a, 0.0); getErrorString();
9393
// ""
9494
// record SimulationResult
9595
// resultFile = "hideResult_res.mat",
96-
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'hideResult', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
96+
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'hideResult', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
9797
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
9898
// LOG_SUCCESS | info | The simulation finished successfully.
9999
// "
100100
// end SimulationResult;
101-
// "Warning: The hideResult annotation could not be evaluated, probably due to missing annotation(Evaluate=true). It is removed.
101+
// "[<interactive>:5:3-5:55:writable] Warning: Ignoring the hideResult annotation on 'b' which could not be evaluated, probably due to missing annotation(Evaluate=true).
102102
// "
103103
// 2.0
104104
// ""
105105
// true
106106
// ""
107107
// record SimulationResult
108108
// resultFile = "hideResult_res.mat",
109-
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'hideResult', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
109+
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'hideResult', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
110110
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
111111
// LOG_SUCCESS | info | The simulation finished successfully.
112112
// "
@@ -119,7 +119,7 @@ val(c.b.a, 0.0); getErrorString();
119119
// ""
120120
// record SimulationResult
121121
// resultFile = "HideResult.hideResult3_res.mat",
122-
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'HideResult.hideResult3', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
122+
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'HideResult.hideResult3', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
123123
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
124124
// LOG_SUCCESS | info | The simulation finished successfully.
125125
// "

0 commit comments

Comments
 (0)