Skip to content

Commit cf2265f

Browse files
Fix Susan array traversal with unused mapped items (#14415)
--------- Co-authored-by: anotheruserofgithub <96748782+anotheruserofgithub@users.noreply.github.com>
1 parent c2aa0e8 commit cf2265f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

OMCompiler/Compiler/Template/TplAbsyn.mo

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,10 +2759,15 @@ algorithm
27592759
(mapstmts, maplocals)
27602760
= addGetIndex(isUsed, freshIdxName, mapstmts, imlicitTxt, maplocals);
27612761

2762-
//assume the array element is the first identifier in case locals
2762+
//define identifiers for array traversal
27632763
idxName = "i";
27642764
arrName = "items";
2765-
(eltName, _) :: _ = caseLocals;
2765+
eltName = match mexp
2766+
case BIND_MATCH(eltName)
2767+
then eltName;
2768+
case REST_MATCH()
2769+
then "";
2770+
end match;
27662771

27672772
mapctx = MAP_CONTEXT(ofbind, mapexp, iopts, hasIndexIdentOpt, useiter);
27682773

OMCompiler/Compiler/boot/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ else()
88
#download and unpack the sources
99
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bomc/)
1010
# the OMBOOTSTRAPPING_GIT_HASH needs updating when the boostrapping sources change
11-
SET(OMBOOTSTRAPPING_GIT_HASH f707623a9b9eed5d67e940e4859e9d92c7eb22f9)
11+
SET(OMBOOTSTRAPPING_GIT_HASH f53f31420ab8a1877b1a423693599028df698e14)
1212
file(DOWNLOAD https://github.com/OpenModelica/OMBootstrapping/archive/${OMBOOTSTRAPPING_GIT_HASH}.tar.gz
1313
${CMAKE_CURRENT_SOURCE_DIR}/bomc/sources.tar.gz
1414
SHOW_PROGRESS

OMCompiler/Compiler/susan_codegen/TplCodegen.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ try
135135
>>
136136
%>
137137
for <%idxName%> in 1:arrayLength(<%arrName%>) loop
138+
<%if eltName then <<
138139
<%eltName%> := arrayGet(<%arrName%>, <%idxName%>);
140+
>>%>
139141
<%statements |> it => '<%mmExp(it, ":=")%>;' ;separator="\n"%>
140142
end for;<% if debugSusan() then
141143
<<

0 commit comments

Comments
 (0)