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: 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)

comment:2 in reply to: ↑ 1 Changed 7 years ago by ceraolo

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 Changed 7 years ago by anonymous

The ModelicaCompliance tests are working again.

comment:4 Changed 7 years ago by perost

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r398b982.

comment:5 Changed 7 years ago by adrpo

  • Milestone changed from 1.13.0 to 1.12.0
Note: See TracTickets for help on using tickets.