Opened 10 years ago
Last modified 10 years ago
#3008 assigned defect
Error in type inference when using function passed to function
Reported by: | Owned by: | Per Östlund | |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Frontend | Version: | |
Keywords: | Cc: |
Description
Consider the package Test:
package Test partial function myFunBase input Real u; output Real y1; output Real y2; end myFunBase; function myFun extends myFunBase; algorithm y1 := u; y2 := 2 * u; end myFun; function myFun2 input myFunBase f; output Real y; protected Real x1,x2; algorithm (x1,x2) := f(2); Y := x1 + x2; end myFun2; model Test Real x(start = 1.0); Real y; equation x = -der(x); y = myFun2(myFun); end Test; end Test;
when validating Test.Test in OMEdit one gets:
"[<interactive>:21:5-21:20:writable] Error: Type mismatch in assignment in (x1, x2) := f(#(2.0)) of (Real, Real) := (#Real, #Real) Error: Error occurred while flattening model Test.Test "
Tested with "OpenModelica 1.9.1+dev (r22423) (Bootstrapping vers".
Note:
See TracTickets
for help on using tickets.
Problem is we cannot cast the results of a function returning multiple arguments to new types, which makes Modelica grammar fail.
This works with MetaModelica grammar because we can make it a "pattern-matching assignment", which is able to perform the type cast.