Skip to content

Commit 6dd5045

Browse files
committed
Add testcase for OM ticket #2974
1 parent bd38afd commit 6dd5045

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

metamodelica/meta/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ StringBoxed.mos \
105105
SwitchString.mos \
106106
TailRecursion.mo \
107107
TailRecursionNoretcall.mos \
108+
Ticket2974.mos \
108109
Ticket3005.mos \
109110
ThreadedReduction.mos \
110111
Try.mos \

metamodelica/meta/Ticket2974.mos

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// status: correct
2+
3+
setCommandLineOptions("-g=MetaModelica");getErrorString();
4+
loadString("
5+
package P
6+
replaceable type T1 subtypeof Any;
7+
replaceable type T2 subtypeof Any;
8+
type Tup = tuple<T1, T2>;
9+
10+
function f
11+
input Tup inTup;
12+
protected
13+
T1 t1;
14+
T2 t2;
15+
algorithm
16+
(t1, t2) := inTup;
17+
print(\"t1 = \" + anyString(t1) + \"\n\");
18+
print(\"t2 = \" + anyString(t2) + \"\n\");
19+
end f;
20+
21+
function f2
22+
input Tup inTup;
23+
protected
24+
T1 t1;
25+
algorithm
26+
(t1, _) := inTup;
27+
f(t1); // *** Calling f with wrong type ***
28+
end f2;
29+
end P;
30+
31+
function test
32+
protected
33+
tuple<Integer, String> tup = (3, \"test\");
34+
algorithm
35+
P.f2(tup);
36+
end test;
37+
");getErrorString();
38+
test();getErrorString();
39+
40+
// Result:
41+
// true
42+
// ""
43+
// true
44+
// ""
45+
//
46+
// "[<interactive>:26:5-26:10:writable] Error: Type mismatch for positional argument 1 in P.f(inTup=t1). The argument has type:
47+
// polymorphic<T1>
48+
// expected type:
49+
// tuple<polymorphic<T1>, polymorphic<T2>>
50+
// [SimCode/SimCodeFunctionUtil.mo:0:0-0:0:writable] Error: Internal error function getCalledFunctionsInFunction2: Class P.f2 not found in global scope.
51+
// [<interactive>:26:5-26:10:writable] Error: Type mismatch for positional argument 1 in P.f(inTup=t1). The argument has type:
52+
// polymorphic<T1>
53+
// expected type:
54+
// tuple<polymorphic<T1>, polymorphic<T2>>
55+
// [SimCode/SimCodeFunctionUtil.mo:0:0-0:0:writable] Error: Internal error function getCalledFunctionsInFunction2: Class P.f2 not found in global scope.
56+
// "
57+
// endResult

0 commit comments

Comments
 (0)