Opened 15 years ago

Last modified 14 years ago

#1207 closed defect (fixed)

Iterator in for loop over enumeration has type Integer instead of EnumType

Reported by: Per Östlund Owned by: Per Östlund
Priority: high Milestone:
Component: Instantiation Version: 1.6.0
Keywords: Cc: Per Östlund,

Description

If an enumeration is used as the range of a for loop then the iterator should be of the same type as the enumeration. The range is instead converted to an Integer range right now, which causes problems with for example the Integer function. See the following model:

model C  
  function find
    input  Integer index;
    output Real value;       
    algorithm
    for j in labels loop
      if index == Integer(j) then value := werte[i]; end if;
    end for;
  end find;

  type labels = enumeration (one "1st", two "2nd");
  constant Real[labels] values := {1.1, 2.2};
  Real valueTwo = find(Integer(labels.two));
end C;  

Change History (1)

comment:1 by Per Östlund, 14 years ago

Fixed in r1207, see test case mofiles/ForIteratorType.

Note: See TracTickets for help on using tickets.