Skip to content

Commit 927872c

Browse files
committed
Fix array dimension type matching
- Return the other dimension if either dimension is unknown in `NFTypeCheck.matchDimensions` instead of just returning the first one.
1 parent 2db926d commit 927872c

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

OMCompiler/Compiler/NFFrontEnd/NFTypeCheck.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ function matchDimensions
22702270
output Dimension compatibleDim;
22712271
output Boolean compatible;
22722272
algorithm
2273-
if Dimension.isEqual(dim1, dim2) then
2273+
if Dimension.isEqualKnown(dim1, dim2) then
22742274
compatibleDim := dim1;
22752275
compatible := true;
22762276
else
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
record R
2+
parameter String components[:];
3+
parameter Integer n = size(components, 1);
4+
end R;
5+
6+
function f
7+
input R r;
8+
output Real x[r.n] = ones(r.n);
9+
end f;
10+
11+
model ArrayEquation1
12+
parameter R r(components = {"a", "b"});
13+
Real x[r.n];
14+
equation
15+
x = f(r);
16+
end ArrayEquation1;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// name: ArrayEquation1
2+
// keywords:
3+
// status: correct
4+
// teardown_command: rm -rf ArrayEquation2_* ArrayEquation2 ArrayEquation2.exe ArrayEquation2.cpp ArrayEquation2.makefile ArrayEquation2.libs ArrayEquation2.log output.log
5+
6+
loadFile("ArrayEquation1.mo");
7+
getErrorString();
8+
simulate(ArrayEquation1);
9+
getErrorString();
10+
11+
// Result:
12+
// true
13+
// ""
14+
// record SimulationResult
15+
// resultFile = "ArrayEquation1_res.mat",
16+
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'ArrayEquation1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
17+
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
18+
// LOG_SUCCESS | info | The simulation finished successfully.
19+
// "
20+
// end SimulationResult;
21+
// ""
22+
// endResult

testsuite/simulation/modelica/equations/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TESTFILES = \
44
VariableSubscriptAlias.mos \
55
ActivateWhenEquation.mos \
66
AliasEquations.mos \
7+
ArrayEquation1.mos \
78
BouncingBall.mos BouncingBall2.mos BouncingBallExamples.mos \
89
constantLinSys.mos \
910
Cross.mos \

0 commit comments

Comments
 (0)