Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Belonging to [master]: - OpenModelica/OMCompiler#2762 - OpenModelica/OpenModelica-testsuite#1069
- Loading branch information
1 parent
88e51f6
commit ba472c6
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// name: FunctionalArg1 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
partial function F | ||
input Real x; | ||
output Real y; | ||
end F; | ||
|
||
function f1 | ||
input F f; | ||
input Real x; | ||
output Real y; | ||
algorithm | ||
y := f(x); | ||
end f1; | ||
|
||
function f2 | ||
input Real x; | ||
output Real y = x * 2; | ||
end f2; | ||
|
||
model FunctionalArg1 | ||
Real x = f1(f2, 1); | ||
end FunctionalArg1; | ||
|
||
// Result: | ||
// function f1 | ||
// input f<function>(#Real x) => #Real f; | ||
// input Real x; | ||
// output Real y; | ||
// algorithm | ||
// y := unbox(f(#(x))); | ||
// end f1; | ||
// | ||
// function f2 | ||
// input Real x; | ||
// output Real y = x * 2.0; | ||
// end f2; | ||
// | ||
// class FunctionalArg1 | ||
// Real x = f1(f2, 1.0); | ||
// end FunctionalArg1; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// name: FunctionalArg2 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
partial function F | ||
input Real x; | ||
output Real y; | ||
end F; | ||
|
||
function f1 | ||
input F f; | ||
input Real x; | ||
output Real y; | ||
algorithm | ||
y := f(x); | ||
end f1; | ||
|
||
function f2 | ||
input Real x; | ||
input Real z = 1.0; | ||
output Real y = x * 2; | ||
end f2; | ||
|
||
model FunctionalArg2 | ||
Real x = f1(f2, 1); | ||
end FunctionalArg2; | ||
|
||
// Result: | ||
// function f1 | ||
// input f<function>(#Real x) => #Real f; | ||
// input Real x; | ||
// output Real y; | ||
// algorithm | ||
// y := unbox(f(#(x))); | ||
// end f1; | ||
// | ||
// function f2 | ||
// input Real x; | ||
// input Real z = 1.0; | ||
// output Real y = x * 2.0; | ||
// end f2; | ||
// | ||
// class FunctionalArg2 | ||
// Real x = f1(f2, 1.0); | ||
// end FunctionalArg2; | ||
// endResult |
40 changes: 40 additions & 0 deletions
40
flattening/modelica/scodeinst/FunctionalArgInvalidType1.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// name: FunctionalArgInvalidType1 | ||
// keywords: | ||
// status: incorrect | ||
// cflags: -d=newInst | ||
// | ||
|
||
partial function F | ||
input Real x; | ||
output Real y; | ||
end F; | ||
|
||
function f1 | ||
input F f; | ||
input Real x; | ||
output Real y; | ||
algorithm | ||
y := f(x); | ||
end f1; | ||
|
||
function f2 | ||
input Integer x; | ||
output Integer y = x * 2; | ||
end f2; | ||
|
||
model FunctionalArgInvalidType1 | ||
Real x = f1(f2, 1); | ||
end FunctionalArgInvalidType1; | ||
|
||
// Result: | ||
// Error processing file: FunctionalArgInvalidType1.mo | ||
// [flattening/modelica/scodeinst/FunctionalArgInvalidType1.mo:26:3-26:21:writable] Error: Type mismatch for positional argument 1 in f1(f=f2). The argument has type: | ||
// f2<function>(Integer) => Integer | ||
// expected type: | ||
// f<function>(#Real) => #Real | ||
// | ||
// # Error encountered! Exiting... | ||
// # Please check the error message and the flags. | ||
// | ||
// Execution failed! | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters