Opened 14 years ago
Last modified 14 years ago
#1430 closed defect (fixed)
Short class definition causes incorrect redeclared function
Reported by: | Per Östlund | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | ||
Keywords: | Cc: | Per Östlund, |
Description
The following model:
partial function part_func input Real x; output Real y; end part_func; function func1 extends part_func; algorithm y := x; end func1; function func2 extends part_func; algorithm y := 2 * x; end func2; model model1 replaceable function func = part_func; Real x; Real y; equation x = func(y); end model1; model model2 = model1(replaceable function func = func1); model model3 = model1(replaceable function func = func2); // This works: //model model2 // extends model1(replaceable function func = func1); //end model2; // //model model3 // extends model1(replaceable function func = func2); //end model3; model model4 model2 m2; model3 m3; end model4;
flattens to:
function model1.func input Real x; output Real y; algorithm y := x; end model1.func; class model4 Real m2.x; Real m2.y; Real m3.x; Real m3.y; equation m2.x = model1.func(m2.y); m3.x = model1.func(m3.y); end model4;
Only one function is generated, but two different functions are actually used. If model2 and model3 are instead declared like in the commented section above we will get two different functions.
Note:
See TracTickets
for help on using tickets.
Fixed a while ago, see test case redeclare/RedeclareFunction1 in r8882. Output is still incorrect because of [bug 1432|BUG:1432], but it no longer fails without an error message.