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

Commit 74abb64

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Improve binding type mismatch error message.
Belonging to [master]: - #2442 - OpenModelica/OpenModelica-testsuite#949
1 parent c02ea2f commit 74abb64

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Compiler/NFFrontEnd/NFTypeCheck.mo

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,7 @@ function matchBinding
21532153
input output Binding binding;
21542154
input Type componentType;
21552155
input String name;
2156+
input InstNode component;
21562157
input InstNode parent;
21572158
algorithm
21582159
() := match binding
@@ -2184,9 +2185,9 @@ algorithm
21842185
(exp, ty, ty_match) := matchTypes(binding.bindingType, comp_ty, binding.bindingExp, true);
21852186

21862187
if not isValidAssignmentMatch(ty_match) then
2187-
Error.addSourceMessage(Error.VARIABLE_BINDING_TYPE_MISMATCH,
2188+
Error.addMultiSourceMessage(Error.VARIABLE_BINDING_TYPE_MISMATCH,
21882189
{name, Binding.toString(binding), Type.toString(comp_ty),
2189-
Type.toString(binding.bindingType)}, Binding.getInfo(binding));
2190+
Type.toString(binding.bindingType)}, {Binding.getInfo(binding), InstNode.info(component)});
21902191
fail();
21912192
elseif isCastMatch(ty_match) then
21922193
binding := Binding.TYPED_BINDING(exp, ty, binding.variability, binding.origin, binding.isEach);

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ algorithm
694694
binding := typeBinding(c.binding, intBitOr(origin, ExpOrigin.BINDING));
695695
checkBindingEach(binding, not Type.isArray(c.ty), InstNode.parent(component));
696696

697-
binding := TypeCheck.matchBinding(binding, c.ty, name, InstNode.derivedParent(node));
697+
binding := TypeCheck.matchBinding(binding, c.ty, name, node, InstNode.derivedParent(node));
698698
comp_var := Component.variability(c);
699699
comp_eff_var := Prefixes.effectiveVariability(comp_var);
700700
bind_var := Prefixes.effectiveVariability(Binding.variability(binding));
@@ -873,7 +873,7 @@ algorithm
873873
// Type and type check the attribute.
874874
checkBindingEach(binding, true, mod_parent);
875875
binding := typeBinding(binding, origin);
876-
binding := TypeCheck.matchBinding(binding, ty, name, mod_parent);
876+
binding := TypeCheck.matchBinding(binding, ty, name, component, mod_parent);
877877

878878
// Check the variability. All builtin attributes have parameter variability.
879879
if Binding.variability(binding) > Variability.PARAMETER then

0 commit comments

Comments
 (0)