Skip to content

Commit 51f6898

Browse files
committed
- Fix Array.map.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23151 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 4587515 commit 51f6898

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Compiler/Util/Array.mo

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ public function map<TI, TO>
130130
end FuncType;
131131
protected
132132
Integer len := arrayLength(inArray);
133+
TO res;
133134
algorithm
134135
// If the array is empty, use list transformations to fix the types!
135136
if len == 0 then
136137
outArray := listArray({});
137138
else
138139
// If the array isn't empty, use the first element to create the new array.
139-
outArray := arrayCreateNoInit(len, inFunc(arrayGetNoBoundsChecking(inArray, 1)));
140+
res := inFunc(arrayGetNoBoundsChecking(inArray, 1));
141+
outArray := arrayCreateNoInit(len, res);
142+
arrayUpdate(outArray, 1, res);
140143

141144
for i in 2:len loop
142145
arrayUpdate(outArray, i, inFunc(arrayGetNoBoundsChecking(inArray, i)));

0 commit comments

Comments
 (0)