Opened 11 years ago
Closed 5 years ago
#3189 closed defect (fixed)
Partial function evaluation and arrays not working
| Reported by: | Gustaf Thorslund | Owned by: | somebody |
|---|---|---|---|
| Priority: | high | Milestone: | 1.16.0 |
| Component: | New Instantiation | Version: | trunk |
| Keywords: | Cc: |
Description
Consider the following example similar to the function passed to function in #3008, but here the return type is an array instead of two values.
package TestArrayP
partial function DerBase
input Real x[:];
output Real dx[size(x)];
end DerBase;
function TheDer
extends DerBase;
input Real x[:];
output Real dx[size(x)];
algorithm
dx := 0.1 * x;
end TheDer;
function Euler
input Real x[:];
input DerBase f;
input Real dt;
output Real xNext[size(x)];
protected
Real dx[size(x)];
algorithm
dx := f(x);
xNext := x + dx * dt;
end Euler;
end TestArrayP;
model TestArray
Real x[2] = {1.0, 2.0};
algorithm
x[1] := 1.0;
x[2] := 2.0;
when sample (0, 0.1) then
x := TestArrayP.Euler(x, TestArrayP.TheDer, 0.1);
end when;
end TestArray;
Trying to compile it gives
$ omc -s TestArray.mo Error processing file: TestArray.mo [.../TestArray.mo:23:5-23:15:writable] Error: Type mismatch in assignment in dx := f(#(x)) of Real[size(x)] := #Real[size(x)] Error: Error occurred while flattening model TestArray # Error encountered! Exiting... # Please check the error message and the flags. Execution failed!
$ omc --version
1.9.2+dev (r24700)
Change History (4)
comment:1 by , 11 years ago
| Component: | Unknown → Frontend |
|---|
comment:2 by , 11 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → accepted |
comment:3 by , 11 years ago
| Owner: | changed from to |
|---|---|
| Status: | accepted → assigned |
comment:4 by , 5 years ago
| Component: | Frontend → New Instantiation |
|---|---|
| Milestone: | Future → 1.16.0 |
| Resolution: | → fixed |
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.

The model is invalid since
size(x)should besize(x, 1)everywhere. Once that's fixed it works fine with the new frontend.