Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#5978 closed defect (invalid)

Unable to pass argument to nested function defined as argument

Reported by: dariomangoni@… 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)

FunctionPass3.zip (2.7 KB ) - added by dariomangoni@… 5 years ago.
minimal example
FunctionPass3_2.zip (1.1 MB ) - added by dariomangoni@… 5 years ago.
new example

Download all attachments as: .zip

Change History (7)

by dariomangoni@…, 5 years ago

Attachment: FunctionPass3.zip added

minimal example

comment:1 by dariomangoni@…, 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 Francesco Casella, 5 years ago

Component: *unknown*New Instantiation
Milestone: Future1.16.0
Owner: changed from somebody to Per Östlund

To be honest, I never fully understood the semantics of parameters in functions

@perost, any comment on this case?

comment:3 by Per Östlund, 5 years ago

Resolution: invalid
Status: newclosed

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.

comment:4 by dariomangoni@…, 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.

by dariomangoni@…, 5 years ago

Attachment: FunctionPass3_2.zip added

new example

in reply to:  4 comment:5 by Per Östlund, 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.

Note: See TracTickets for help on using tickets.