Opened 14 years ago

Last modified 14 years ago

#1190 closed defect (fixed)

Function default parameters and unknown dimensions

Reported by: sjoelund.se Owned by: sjoelund.se
Priority: high Milestone:
Component: Instantiation Version: 1.5.0RC2
Keywords: Cc: sjoelund.se,

Description

The issue here is of course that constants in Modelica aren't constants at
all. They can be modified when extending, etc (how fun!).

So consider the model below. Right now, OpenModelica will look at
reference_X and say: This function takes input Integer[3]. And will then
happily cache the result. Then we try to call this function below with
an Integer[4], and we get an error. We could also extend from this model
twice and setting reference_X to different dimensions in both :)

model evil
   constant Integer[:] reference_X = {1,2,3};
   function set
     input Integer X[:] = reference_X;
     output Integer x1;
   algorithm
     x1 := X[1];
   end set;
   Integer res1;
equation
   res1 = set({4,5,6,7});
end evil;

Change History (2)

comment:1 Changed 14 years ago by perost

Fixed the formatting of the model.

comment:2 Changed 14 years ago by perost

Fixed in revision 5301.

Note: See TracTickets for help on using tickets.