#5978 closed defect (invalid)
Unable to pass argument to nested function defined as argument
Reported by: | Owned by: | Per Östlund | |
---|---|---|---|
Priority: | normal | Milestone: | 1.16.0 |
Component: | New Instantiation | Version: | v1.16.0-dev |
Keywords: | Cc: |
Description
I have an outer function that have:
- a Real argument
- a function
Passing the real argument to the function results in:
Function parameter inVal was not given by the function call, and does not have a default value.
I'm on OpenModelica v1.16.0-dev-275-g033f38916
Attachments (2)
Change History (7)
by , 5 years ago
Attachment: | FunctionPass3.zip added |
---|
comment:1 by , 5 years ago
P.S. it suffices to declare
myInnerFun=FunctionPass3.Functions.InnerFun()
to
myInnerFun=FunctionPass3.Functions.InnerFun
to make it work.
In Dymola no warning were thrown so I cannot say if it is a bug or not.
comment:2 by , 5 years ago
Component: | *unknown* → New Instantiation |
---|---|
Milestone: | Future → 1.16.0 |
Owner: | changed from | to
To be honest, I never fully understood the semantics of parameters in functions
@perost, any comment on this case?
comment:3 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
FunctionPass3.Functions.InnerFun()
is a function call, which fails due to the reason given in the error message. FunctionPass3.Functions.InnerFun
on the other hand is a function reference, so no argument is needed and indeed not expected. So from what I can see this is working as intended.
follow-up: 5 comment:4 by , 5 years ago
Can I have another opportunity here? :-)
My previous example was too minimal. The real issue is when the function argument is binded, that is not what I posted initially.
The very same error happens when I bind an argument to InnerFun
like this
myInnerFun=FunctionPass3.Functions.InnerFun(k=1)
Previously the function argument was passed without any binding and it was working, but that is not what I wanted.
comment:5 by , 5 years ago
Replying to dariomangoni@…:
The very same error happens when I bind an argument to
InnerFun
like this
myInnerFun=FunctionPass3.Functions.InnerFun(k=1)
Because that's still a function call and not a modification. If you want to modify myInnerFun
I guess you need to redeclare it.
minimal example