Opened 4 years ago
Last modified 3 years ago
#6352 accepted defect
Function returning record with array fails
Reported by: | Francesco Casella | Owned by: | Mahder Alemseged Gebremedhin |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Code Generation | Version: | v1.17.0-dev |
Keywords: | Cc: | Karim Adbdelhak, Andreas Heuermann, Per Östlund |
Description
Please consider this test model (also attached)
model TestFunctionRecordArray constant Integer c = 3; record R Real v; Real x[c]; end R; function f input Real v; output R rout; algorithm rout.v := v; rout.x := {0.3, 0.4, 0.3}; end f; Real x; R r; equation x = time; r = f(x); end TestFunctionRecordArray;
The model fails during compilation with
TestFunctionRecordArray_functions.c:33:3: error: use of undeclared identifier '_rout' _rout._x = _OMC_LIT0; ^
Attachments (1)
Change History (5)
by , 4 years ago
Attachment: | TestFunctionRecordArray.mo added |
---|
comment:2 by , 4 years ago
Replying to mahge930:
Per is the last person who has modified the relevant part of the code. So hopefully he can find it easier.
Not really, I just made some changes to DAE.FUNCTION a while ago that just happened to touch that code. No one seems to have made any significant changes to EvaluateFunctions in the last 5-6 years.
comment:3 by , 4 years ago
Status: | new → accepted |
---|
Note:
See TracTickets
for help on using tickets.
This is what the generated code for the function looks:
The error message is for this assignment
A few things to notice here. First the function name is different. It seems there was an attempt to evaluate the function as you can see from the new name it has got
f__eval1
instead of justf
. This is done by the backed here.The output of the function is also changed from a record to just a real variable. Probably by the same code in the backend. I am not sure why this is done.
The body, however, seems to have been half-way fixed to match the changes. The assignment to the variable
rout.v
of the record is fixed to a simple variablerout_v
to reflect that there is no record anymore. However the array assignment ofrout.x
has not been changed. My guess is that a missing case or similar matching failure.Per is the last person who has modified the relevant part of the code. So hopefully he can find it easier. If not I will take a look later next week.