Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4521 closed defect (fixed)

OM does not allow omitting a function output

Reported by: massimo ceraolo Owned by: somebody
Priority: normal Milestone: 1.12.0
Component: *unknown* Version:
Keywords: Cc:

Description

Modelica specifications allow to use function calls in which only part of the function outputs are used (MS 3.3 rev2 sect. 12.4.3).
However in some cases this is not accepted by OM.
Consider the following package:

package TestRealFun
  model TestMdl
    parameter Real Z[2] = TestFun(2, {1.0, 2.0});
  end TestMdl;

  function TestFun "returns an array and a scalar"
    input Integer n;
    input Real x[n];
    output Real z1[n];
    output Real z2;
  algorithm
    for i in 1:n loop
      z1[i] := x[i];
    end for;
    z2 := 2 * x[1];
  end TestFun;

end TestRealFun;

If we run TestMdl we get the following error:

[1] 21:35:17 Translation Error
[TestRealFun: 3:5-3:49]: Type mismatch in modifier of component Z, declared type Real[2], got modifier ({1.0, 2.0}, 2.0) of type (Real[2], Real).

[2] 21:35:17 Translation Error
Error occurred while flattening model TestRealFun.TestMdl

Tested with OM 1.12 beta1 for win 64

Change History (5)

in reply to:  1 comment:2 by massimo ceraolo, 7 years ago

Replying to tbc@…:

See ModelicaCompliance.Functions.Calls.CallMultiResultsWithOmittedOutput2.

Nice.
You've used much better names than mine.
Once this is solved, I will try this pattern also with complex numbers (that is where my names with "z" came from).

comment:3 by anonymous, 7 years ago

The ModelicaCompliance tests are working again.

comment:4 by Per Östlund, 7 years ago

Resolution: fixed
Status: newclosed

Fixed in r398b982.

comment:5 by Adrian Pop, 7 years ago

Milestone: 1.13.01.12.0
Note: See TracTickets for help on using tickets.