Opened 11 years ago
Last modified 6 years ago
#2276 reopened defect
detecting size mismatch for output arguments in functions
Reported by: | Willi Braun | Owned by: | somebody |
---|---|---|---|
Priority: | normal | Milestone: | 2.1.0 |
Component: | New Instantiation | Version: | trunk |
Keywords: | Cc: | Per Östlund |
Description
Following model runs into an segmentation fault, since we set the unknown size to 99.
model test1 function f1 input Real u; output Real y[:]; algorithm for i in 1:5 loop y[i] := i+u; end for; end f1; Real z[5]; equation z = f1(time); end test1;
But it should end up with an flatting error like the constant case.
model test1 function f1 output Real y[:]; // unknown size algorithm for i in 1:5 loop y[i] := i; end for; end f1; Real z[5]; equation z = f1(); end test1;
[<interactive>:50:3-50:11:writable] Error: Array equation has unknown size in {z[1], z[2], z[3], z[4], z[5]}={1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}. [<interactive>:50:3-50:11:writable] Error: Type mismatch in equation {z[1], z[2], z[3], z[4], z[5]}={1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} of type Real[5]=Real[:]. Error: Error occurred while flattening model test1
Change History (12)
comment:1 by , 11 years ago
Milestone: | 1.9.0 → 1.9.1 |
---|
comment:2 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:3 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:8 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:9 by , 7 years ago
Cc: | added |
---|---|
Component: | Frontend → New Instantiation |
Milestone: | 1.12.0 → 2.0.0 |
Resolution: | → worksforme |
Status: | new → closed |
With the new instantiation the following error is generated:
[1] 01:34:08 Translation Error [test1: 3:5-3:21]: Failed to deduce dimension 1 of y due to missing binding equation.
comment:10 by , 7 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
That error is due to the function being instantiated like a normal class, and wrong since function parameters are allowed to have unknown size. I'm not quite sure what the expected behaviour here actually is, the specification is very vague regarding unknown dimensions.
We should definitely check that the function parameter is assigned to correctly, i.e. given a size by assignment in the algorithm. Handling outputs with unknown size is a bit tricky since they can change size according to what's assigned to them, so we might have to just forbid using such functions like this.
comment:12 by , 6 years ago
Milestone: | 2.0.0 → 2.1.0 |
---|
Postponed until 1.9.1