Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
include function name in the error message for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Aug 12, 2018
1 parent ceb595e commit 363af9f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -102,7 +102,7 @@ annotation(Documentation(info="<html>
</html>"));
end floor;

function integer "Round a real number towards minus infinity"
function integer "Returns the largest integer not greater than x. The argument shall have type Real. The result has type Integer. [Note, outside of a when-clause state events are triggered when the return value changes discontinuously.]."
input Real x;
output Integer y;
external "builtin";
Expand Down
19 changes: 10 additions & 9 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -9702,7 +9702,7 @@ algorithm
case (cache, env, e, DAE.FUNCARG(name=id,ty = vt as DAE.T_CODE(ct),par=pr), _, slots, _, true, _, polymorphicBindings,pre)
equation
e_1 = elabCodeExp(e,cache,env,ct,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,DAE.C_VAR(),pr,NONE()), e_1, {}, slots,pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,DAE.C_VAR(),pr,NONE()), e_1, {}, slots,pre,info, path);
then
(cache,slots_1,DAE.C_VAR(),polymorphicBindings);

Expand All @@ -9714,7 +9714,7 @@ algorithm
vt = Types.traverseType(vt, -1, Types.makeExpDimensionsUnknown);
c1 = Types.propAllConst(props);
(e_2,_,polymorphicBindings) = Types.matchTypePolymorphic(e_1,t,vt,FGraph.getGraphPathNoImplicitScope(env),polymorphicBindings,false);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, {}, slots,pre,info) "no vectorized dim" ;
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, {}, slots,pre,info, path) "no vectorized dim" ;
then
(cache,slots_1,c1,polymorphicBindings);

Expand All @@ -9726,7 +9726,7 @@ algorithm
vt = Types.traverseType(vt, -1, Types.makeExpDimensionsUnknown);
c1 = Types.propAllConst(props);
(e_2,_,ds,polymorphicBindings) = Types.vectorizableType(e_1, t, vt, FGraph.getGraphPathNoImplicitScope(env));
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, ds, slots, pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, ds, slots, pre,info, path);
then
(cache,slots_1,c1,polymorphicBindings);

Expand All @@ -9737,7 +9737,7 @@ algorithm
t = Types.getPropType(props);
c1 = Types.propAllConst(props);
/* fill slot with actual type for error message*/
slots_1 = fillSlot(DAE.FUNCARG(id,t,c1,pr,NONE()), e_1, {}, slots, pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,t,c1,pr,NONE()), e_1, {}, slots, pre,info, path);
then
(cache,slots_1,c1,polymorphicBindings);

Expand Down Expand Up @@ -9872,7 +9872,7 @@ algorithm
(vt as DAE.T_CODE(ty=ct)) = findNamedArgType(id, farg);
pr = findNamedArgParallelism(id,farg);
e_1 = elabCodeExp(e,cache,env,ct,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,DAE.C_VAR(),pr,NONE()), e_1, {}, slots,pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,DAE.C_VAR(),pr,NONE()), e_1, {}, slots,pre,info, path);
then (cache,slots_1,DAE.C_VAR(),polymorphicBindings);

// check types exact match
Expand All @@ -9882,7 +9882,7 @@ algorithm
pr = findNamedArgParallelism(id,farg);
(cache,e_1,DAE.PROP(t,c1)) = elabExpInExpression(cache, env, e, impl, true,pre,info);
(e_2,_,polymorphicBindings) = Types.matchTypePolymorphic(e_1,t,vt,FGraph.getGraphPathNoImplicitScope(env),polymorphicBindings,false);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, {}, slots,pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, {}, slots,pre,info, path);
then (cache,slots_1,c1,polymorphicBindings);

// check types vectorized argument
Expand All @@ -9892,7 +9892,7 @@ algorithm
pr = findNamedArgParallelism(id,farg);
(cache,e_1,DAE.PROP(t,c1)) = elabExpInExpression(cache, env, e, impl, true,pre,info);
(e_2,_,ds,polymorphicBindings) = Types.vectorizableType(e_1, t, vt, FGraph.getGraphPathNoImplicitScope(env));
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, ds, slots, pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_2, ds, slots, pre,info, path);
then (cache,slots_1,c1,polymorphicBindings);

// do not check types
Expand All @@ -9901,7 +9901,7 @@ algorithm
vt = findNamedArgType(id, farg);
pr = findNamedArgParallelism(id,farg);
(cache,e_1,DAE.PROP(_,c1)) = elabExpInExpression(cache,env, e, impl,true,pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_1, {}, slots,pre,info);
slots_1 = fillSlot(DAE.FUNCARG(id,vt,c1,pr,NONE()), e_1, {}, slots,pre,info, path);
then (cache,slots_1,c1,polymorphicBindings);

case (cache, _, Absyn.NAMEDARG(argName = id), farg, slots, true /* only 1 function */, _, _, polymorphicBindings,_)
Expand Down Expand Up @@ -9978,6 +9978,7 @@ protected function fillSlot
input list<Slot> inSlotLst;
input Prefix.Prefix inPrefix;
input SourceInfo inInfo;
input Absyn.Path fn;
output list<Slot> outSlotLst = {};
protected
String fa1, fa2, exp_str, c_str, pre_str;
Expand Down Expand Up @@ -10013,7 +10014,7 @@ algorithm
exp_str := ExpressionDump.printExpStr(inExp);
c_str := Types.unparseConst(c2);
Error.addSourceMessageAndFail(Error.FUNCTION_SLOT_VARIABILITY,
{fa1, exp_str, Types.unparseConst(c1), c_str}, inInfo);
{fa1, exp_str, Absyn.pathStringNoQual(fn), Types.unparseConst(c1), c_str}, inInfo);
end if;

// Found a valid slot, fill it and reconstruct the slot list.
Expand Down
2 changes: 2 additions & 0 deletions Compiler/NFFrontEnd/NFFunction.mo
Expand Up @@ -798,6 +798,7 @@ uniontype Function
correct := false;
Error.addSourceMessage(Error.FUNCTION_SLOT_VARIABILITY, {
InstNode.name(inputnode), Expression.toString(argexp),
Absyn.pathString(Function.name(func)),
Prefixes.variabilityString(var),
Prefixes.variabilityString(Component.variability(comp))
}, info);
Expand Down Expand Up @@ -866,6 +867,7 @@ uniontype Function
correct := false;
Error.addSourceMessage(Error.FUNCTION_SLOT_VARIABILITY, {
InstNode.name(inputnode), Expression.toString(argexp),
Absyn.pathString(name(func)),
Prefixes.variabilityString(var),
Prefixes.variabilityString(Component.variability(comp))
}, info);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -347,7 +347,7 @@ algorithm

else
algorithm
Error.assertion(false, getInstanceName() + " got unknown class", sourceInfo());
Error.assertion(false, getInstanceName() + " got unknown class:\n" + SCodeDump.unparseElementStr(def), sourceInfo());
then
fail();

Expand Down
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFModelicaBuiltin.mo
Expand Up @@ -106,7 +106,7 @@ annotation(Documentation(info="<html>
</html>"));
end floor;

function integer "Round a real number towards minus infinity"
function integer "Returns the largest integer not greater than x. The argument shall have type Real. The result has type Integer. [Note, outside of a when-clause state events are triggered when the return value changes discontinuously.]."
input Real x;
output Integer y;
external "builtin";
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Util/Error.mo
Expand Up @@ -518,7 +518,7 @@ public constant Message ARRAY_TYPE_MISMATCH = MESSAGE(193, TRANSLATION(), ERROR(
public constant Message VECTORIZE_TWO_UNKNOWN = MESSAGE(194, TRANSLATION(), ERROR(),
Util.gettext("Could not vectorize call with unknown dimensions due to finding two for-iterators: %s and %s."));
public constant Message FUNCTION_SLOT_VARIABILITY = MESSAGE(195, TRANSLATION(), ERROR(),
Util.gettext("Function argument %s=%s with variability %s is not a %s expression."));
Util.gettext("Function argument %s=%s in call to %s has variability %s which is not a %s expression."));
public constant Message INVALID_ARRAY_DIM_IN_CONVERSION_OP = MESSAGE(196, TRANSLATION(), ERROR(),
Util.gettext("Invalid dimension %s of argument to %s, expected dimension size %s but got %s."));
public constant Message DUPLICATE_REDECLARATION = MESSAGE(197, TRANSLATION(), ERROR(),
Expand Down

0 comments on commit 363af9f

Please sign in to comment.