Skip to content

Commit

Permalink
[NF] Improve binding type mismatch error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed May 17, 2018
1 parent c02ea2f commit 74abb64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Compiler/NFFrontEnd/NFTypeCheck.mo
Expand Up @@ -2153,6 +2153,7 @@ function matchBinding
input output Binding binding;
input Type componentType;
input String name;
input InstNode component;
input InstNode parent;
algorithm
() := match binding
Expand Down Expand Up @@ -2184,9 +2185,9 @@ algorithm
(exp, ty, ty_match) := matchTypes(binding.bindingType, comp_ty, binding.bindingExp, true);

if not isValidAssignmentMatch(ty_match) then
Error.addSourceMessage(Error.VARIABLE_BINDING_TYPE_MISMATCH,
Error.addMultiSourceMessage(Error.VARIABLE_BINDING_TYPE_MISMATCH,
{name, Binding.toString(binding), Type.toString(comp_ty),
Type.toString(binding.bindingType)}, Binding.getInfo(binding));
Type.toString(binding.bindingType)}, {Binding.getInfo(binding), InstNode.info(component)});
fail();
elseif isCastMatch(ty_match) then
binding := Binding.TYPED_BINDING(exp, ty, binding.variability, binding.origin, binding.isEach);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -694,7 +694,7 @@ algorithm
binding := typeBinding(c.binding, intBitOr(origin, ExpOrigin.BINDING));
checkBindingEach(binding, not Type.isArray(c.ty), InstNode.parent(component));

binding := TypeCheck.matchBinding(binding, c.ty, name, InstNode.derivedParent(node));
binding := TypeCheck.matchBinding(binding, c.ty, name, node, InstNode.derivedParent(node));
comp_var := Component.variability(c);
comp_eff_var := Prefixes.effectiveVariability(comp_var);
bind_var := Prefixes.effectiveVariability(Binding.variability(binding));
Expand Down Expand Up @@ -873,7 +873,7 @@ algorithm
// Type and type check the attribute.
checkBindingEach(binding, true, mod_parent);
binding := typeBinding(binding, origin);
binding := TypeCheck.matchBinding(binding, ty, name, mod_parent);
binding := TypeCheck.matchBinding(binding, ty, name, component, mod_parent);

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

0 comments on commit 74abb64

Please sign in to comment.