Skip to content

Commit 08f4d8d

Browse files
committed
Use the file info from the binding when generating an error about type mismatch in the binding (since it is very hard to know where the binding is coming from compared to finding out the type of the declared component)
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21916 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent b6d6d29 commit 08f4d8d

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

Compiler/FrontEnd/InstBinding.mo

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -948,10 +948,9 @@ Unless it is a complex var that not inherites a basic type. In that case DAE.Equ
948948
input DAE.Const const;
949949
input Prefix.Prefix pre;
950950
input String name;
951-
input DAE.ElementSource source;
952951
output Option<DAE.Exp> eOpt;
953952
algorithm
954-
eOpt := matchcontinue(tp,mod,const,pre,name,source)
953+
eOpt := matchcontinue(tp,mod,const,pre,name)
955954
local
956955
DAE.Exp e,e1;
957956
DAE.Properties p;
@@ -963,37 +962,36 @@ algorithm
963962
Absyn.Info info;
964963

965964
case (DAE.T_COMPLEX(complexClassType=ClassInf.EXTERNAL_OBJ(_)),
966-
DAE.MOD(eqModOption = SOME(DAE.TYPED(modifierAsExp = e))),_,_,_,_)
965+
DAE.MOD(eqModOption = SOME(DAE.TYPED(modifierAsExp = e))),_,_,_)
967966
then
968967
SOME(e);
969968

970-
case(_,_,c,pr,n,_)
969+
case(_,_,c,pr,n)
971970
equation
972-
SOME(DAE.TYPED(e,_,p,_,_)) = Mod.modEquation(mod);
971+
SOME(DAE.TYPED(modifierAsExp=e,properties=p,info=info)) = Mod.modEquation(mod);
973972
(e1,DAE.PROP(_,c1)) = Types.matchProp(e,p,DAE.PROP(tp,c),true);
974-
InstUtil.checkHigherVariability(c,c1,pr,n,e,source);
973+
InstUtil.checkHigherVariability(c,c1,pr,n,e,info);
975974
then
976975
SOME(e1);
977976

978977
// An empty array such as x[:] = {} will cause Types.matchProp to fail, but we
979978
// shouldn't print an error.
980-
case (_, _, _, _, _, _)
979+
case (_, _, _, _, _)
981980
equation
982981
SOME(DAE.TYPED(_,_,DAE.PROP(type_ = bt),_,_)) = Mod.modEquation(mod);
983982
true = Types.isEmptyArray(bt);
984983
then
985984
NONE();
986985

987986
// If Types.matchProp fails, print an error.
988-
case (_, _, c, _, n, _)
987+
case (_, _, c, _, n)
989988
equation
990-
SOME(DAE.TYPED(e,_,p as DAE.PROP(type_ = bt),_,_)) = Mod.modEquation(mod);
989+
SOME(DAE.TYPED(modifierAsExp=e,properties=p as DAE.PROP(type_ = bt),info=info)) = Mod.modEquation(mod);
991990
failure((_,DAE.PROP(_,_)) = Types.matchProp(e, p, DAE.PROP(tp, c), true));
992991
v_str = n;
993992
b_str = ExpressionDump.printExpStr(e);
994993
et_str = Types.unparseType(tp);
995994
bt_str = Types.unparseType(bt);
996-
info = DAEUtil.getElementSourceFileInfo(source);
997995
Types.typeErrorSanityCheck(et_str, bt_str, info);
998996
Error.addSourceMessage(Error.VARIABLE_BINDING_TYPE_MISMATCH,
999997
{v_str, b_str, et_str, bt_str}, info);

Compiler/FrontEnd/InstUtil.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,9 +3664,9 @@ Helper to makeVariableBinding. Author -- alleb"
36643664
input Prefix.Prefix pre;
36653665
input String name;
36663666
input DAE.Exp binding;
3667-
input DAE.ElementSource source;
3667+
input Absyn.Info info;
36683668
algorithm
3669-
_ := matchcontinue(compConst,bindConst,pre,name,binding,source)
3669+
_ := matchcontinue(compConst,bindConst,pre,name,binding,info)
36703670
local
36713671
DAE.Const c,c1;
36723672
Ident n;
@@ -3692,7 +3692,7 @@ algorithm
36923692
sc = DAEUtil.constStr(c);
36933693
sc1 = DAEUtil.constStr(c1);
36943694
se = ExpressionDump.printExpStr(e);
3695-
Error.addSourceMessage(Error.HIGHER_VARIABILITY_BINDING,{sn,sc,se,sc1}, DAEUtil.getElementSourceFileInfo(source));
3695+
Error.addSourceMessage(Error.HIGHER_VARIABILITY_BINDING,{sn,sc,se,sc1}, info);
36963696
then
36973697
fail();
36983698
end matchcontinue;

Compiler/FrontEnd/InstVar.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ algorithm
581581
false = Types.isExternalObject(Types.arrayElementType(ty));
582582
false = Types.isComplexType(Types.arrayElementType(ty));
583583
(dims as _::_) = Types.getDimensions(ty);
584-
SOME(exp) = InstBinding.makeVariableBinding(ty, mod, const, pre, n, source);
584+
SOME(exp) = InstBinding.makeVariableBinding(ty, mod, const, pre, n);
585585
cr = ComponentReference.makeCrefIdent(n,ty,{});
586586
(cache,cr) = PrefixUtil.prefixCref(inCache,inEnv,inIH,pre,cr);
587587
eq = DAE.ARRAY_EQUATION(dims, DAE.CREF(cr,ty), exp, source);
@@ -1002,7 +1002,7 @@ algorithm
10021002

10031003
// Instantiate the components binding.
10041004
mod = Util.if_(List.isNotEmpty(inSubscripts) and not SCode.isParameterOrConst(vt) and not ClassInf.isFunctionOrRecord(inState) and not Types.isComplexType(Types.arrayElementType(ty)) and not Types.isExternalObject(Types.arrayElementType(ty)) and not Config.scalarizeBindings(),DAE.NOMOD(),inMod);
1005-
opt_binding = InstBinding.makeVariableBinding(ty, mod, NFInstUtil.toConst(vt), inPrefix, inName, source);
1005+
opt_binding = InstBinding.makeVariableBinding(ty, mod, NFInstUtil.toConst(vt), inPrefix, inName);
10061006
start = InstBinding.instStartBindingExp(inMod /* Yup, let's keep the start-binding. It seems sane. */, ty, vt);
10071007

10081008
// Propagate the final prefix from the modifier.

0 commit comments

Comments
 (0)