Skip to content

Commit

Permalink
Detect der() being used inside a function
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24289 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 29, 2015
1 parent 3736f27 commit 678e229
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -5569,6 +5569,10 @@ protected
list<DAE.Dimension> dims;
String exp_str, ty_str;
algorithm
if FGraph.inFunctionScope(inEnv) then
Error.addSourceMessageAndFail(Error.DERIVATIVE_FUNCTION_CONTEXT, {}, inInfo);
end if;

checkBuiltinCallArgs(inPosArgs, inNamedArgs, 1, "der", inInfo);

(outCache, outExp, outProperties) := elabExpInExpression(inCache, inEnv,
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Util/Error.mo
Expand Up @@ -675,6 +675,8 @@ public constant Message RESERVED_IDENTIFIER = MESSAGE(254, TRANSLATION(), ERROR(
Util.gettext("Identifier %s is reserved for the built-in type with the same name."));
public constant Message NOTIFY_IMPACT_FOUND = MESSAGE(255, SCRIPTING(), NOTIFICATION(),
Util.gettext("The impact package manager downloaded package %s%s to directory %s."));
public constant Message DERIVATIVE_FUNCTION_CONTEXT = MESSAGE(256, SCRIPTING(), ERROR(),
Util.gettext("The der() operator is not allowed in function context (possible solutions: pass the derivative as an explicit input; use a block instead of function)."));

public constant Message UNBOUND_PARAMETER_WITH_START_VALUE_WARNING = MESSAGE(499, TRANSLATION(), WARNING(),
Util.gettext("Parameter %s has no value, and is fixed during initialization (fixed=true), using available start value (start=%s) as default value."));
Expand Down

0 comments on commit 678e229

Please sign in to comment.