Skip to content

Commit

Permalink
Add test for invalid function pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Mar 16, 2018
1 parent a3c91c4 commit 27c536c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions flattening/modelica/algorithms-functions/Makefile
Expand Up @@ -98,6 +98,7 @@ SumSeriesWhile.mo \
SumVectorForIf.mo \
TestGravityAcceleration.mo \
Ticket4365.mos \
Ticket4786.mo \
TupleError.mo \
TupleSingleAssign.mo \
TupleAssignmentMismatch1.mo \
Expand Down
40 changes: 40 additions & 0 deletions flattening/modelica/algorithms-functions/Ticket4786.mo
@@ -0,0 +1,40 @@
// status: incorrect

model M

function f
input Integer i;
input FuncT func;

partial function FuncT
input String s;
end FuncT;
algorithm
func(String(i));
end f;

function wrongType
input Integer i;
input Integer i2 = 1;
algorithm
print(String(i) + "\n");
print(String(i2) + "\n");
end wrongType;

algorithm
f(1, function wrongType());
end M;

// Result:
// Error processing file: Ticket4786.mo
// [flattening/modelica/algorithms-functions/Ticket4786.mo:25:3-25:29:writable] Error: Type mismatch for positional argument 2 in M.f(func=M.wrongType). The argument has type:
// .M.wrongType<function>(#Integer i, #Integer i2 := 1) => #NORETCALL#
// expected type:
// .M.f.FuncT<function>(String s) => #NORETCALL#
// Error: Error occurred while flattening model M
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// endResult

0 comments on commit 27c536c

Please sign in to comment.