-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix argument order of partial function application (#12504)
- Rewrite `Function.typePartialApplication` to use a slot-based approach like normal function calls, to make sure the arguments of the partial application have the same order as the corresponding input parameters. - Change the "no such parameter" error to "no such input parameter" in a few places to be more consistent. Fixes #12491
- Loading branch information
Showing
5 changed files
with
116 additions
and
50 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
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
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
66 changes: 66 additions & 0 deletions
66
testsuite/flattening/modelica/scodeinst/PartialApplication3.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,66 @@ | ||
// name: PartialApplication3 | ||
// keywords: | ||
// status: correct | ||
// cflags: -d=newInst | ||
// | ||
|
||
partial function pf | ||
input Real x; | ||
output Real z; | ||
end pf; | ||
|
||
function f1 | ||
input Real x; | ||
input pf f; | ||
output Real z; | ||
algorithm | ||
z := f(x); | ||
end f1; | ||
|
||
function f2 | ||
input Real x; | ||
input Real y; | ||
input Real w; | ||
output Real z = x + y + w; | ||
end f2; | ||
|
||
function f3 | ||
input Real x; | ||
input Real y; | ||
output Real z; | ||
algorithm | ||
z := f1(x, function f2(w = y, y = x)); | ||
end f3; | ||
|
||
model PartialApplication3 | ||
Real x = f3(time, time); | ||
end PartialApplication3; | ||
|
||
// Result: | ||
// function f1 | ||
// input Real x; | ||
// input f<function>(#Real x) => #Real f; | ||
// output Real z; | ||
// algorithm | ||
// z := unbox(f(#(x))); | ||
// end f1; | ||
// | ||
// function f2 | ||
// input Real x; | ||
// input Real y; | ||
// input Real w; | ||
// output Real z = x + y + w; | ||
// end f2; | ||
// | ||
// function f3 | ||
// input Real x; | ||
// input Real y; | ||
// output Real z; | ||
// algorithm | ||
// z := f1(x, function f2(#(x), #(y))); | ||
// end f3; | ||
// | ||
// class PartialApplication3 | ||
// Real x = f3(time, time); | ||
// end PartialApplication3; | ||
// 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