Opened 9 years ago

Last modified 6 years ago

#4054 closed defect

Binding equation does not accept reduced-outputs function calls — at Version 1

Reported by: massimo ceraolo Owned by: somebody
Priority: high Milestone: 2.0.0
Component: Frontend Version:
Keywords: Cc:

Description (last modified by massimo ceraolo)

Consider the following code:

package VectorBinding
  function AddVector2 
    input Integer n;
    input Real x[n], y[n];
    output Real z[n];
    output Real z2;
  algorithm
    z := x + y;
    z2 := 2;
  end AddVector2;

model TestVector2 
  parameter Real sum[2] = AddVector2(n = 2, x = {0.2, 0.2}, y = {0.1, 0.2});
  Real y;
equation
  y=sum[1]+sum[2]; 
end TestVector2;
  annotation(uses(Modelica(version = "3.2.2")));
end VectorBinding;

The binding equation defining sum[] calls a function but exploits only the first output.
It seems to me that, according to MSL (sect. 12.4.3) this should be considered valid Modelica code.
However OM does not accept this. When checking "TestVector2", it issues the following message:

[1] 12:19:04 Translation Error
[VectorBinding: 14:3-14:76]: Type mismatch in modifier of component sum, declared type Real[2], got modifier ({0.3, 0.4}, 2.0) of type (Real[2], Real).

[2] 12:19:04 Translation Error
Error occurred while flattening model VectorBinding.TestVector2

The issue seems to be related to the fact that the first output is an array: it works if it is scalar.

Tested with OpenModelica v1.11.0-dev-79-g5ac7218

Change History (1)

comment:1 by massimo ceraolo, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.