Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 8cd9743

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix root class modifiers.
- Allow ComponentRef.subscriptsN to handle N larger than the number of subscript parts. This can happen when the root class is a short class definition with modifiers. Belonging to [master]: - #2885
1 parent 683050e commit 8cd9743

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Compiler/NFFrontEnd/NFComponentRef.mo

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,7 @@ public
428428
end subscriptsAllFlat;
429429

430430
function subscriptsN
431-
"Returns the subscripts of the N first parts of a cref in reverse order.
432-
Fails if the cref has fewer than N parts."
431+
"Returns the subscripts of the N first parts of a cref in reverse order."
433432
input ComponentRef cref;
434433
input Integer n;
435434
output list<list<Subscript>> subscripts = {};
@@ -438,6 +437,10 @@ public
438437
ComponentRef rest = cref;
439438
algorithm
440439
for i in 1:n loop
440+
if isEmpty(rest) then
441+
break;
442+
end if;
443+
441444
CREF(subscripts = subs, restCref = rest) := rest;
442445
subscripts := subs :: subscripts;
443446
end for;

0 commit comments

Comments
 (0)