Opened 10 years ago

Closed 10 years ago

#3173 closed defect (invalid)

Array index not detected as integer

Reported by: Henning Kiel Owned by: somebody
Priority: high Milestone:
Component: Frontend Version: trunk
Keywords: Cc:

Description (last modified by Henning Kiel)

The following model does not flatten:

model demo
  Real x[8] = {1, 2, 3, 4, 5, 6, 7, 8};
  Real y;
algorithm
  y := 0;
  for j in 1:3 loop
    y := y + x[j * (j + 1) / 2];
  end for;
end demo;
[demo.mo:7:5-7:32:writable] Error: Subscript j * (j + 1) / 2 of type Real is not a subtype of Integer, Boolean or enumeration.
[demo.mo:7:5-7:32:writable] Error: Variable x[j * (j + 1) / 2] not found in scope demo.$for loop scope$.
Error: Error occurred while flattening model demo

Change History (2)

comment:1 by Henning Kiel, 10 years ago

Description: modified (diff)

comment:2 by Martin Sjölund, 10 years ago

Component: UnknownFrontend
Milestone: Future
Resolution: invalid
Status: newclosed

Division in Modelica always returns a Real, never an Integer. Use div() for integer division.

Note: See TracTickets for help on using tickets.