Opened 3 years ago

Last modified 21 months ago

## #5316 new defect

# Handle different kinds of for loop constructions

Reported by: | aramle | Owned by: | Jesper Mattsson |
---|---|---|---|

Priority: | major | Milestone: | |

Component: | Modelica/FrontEnd | Version: | trunk |

Keywords: | Cc: |

### Description (last modified by )

The following for loop constructions are not handled correctly/supported in the compiler, the concepts are described in 11.2 in the Modelica specification:

Boolean b[Boolean]; algorithm for i in false:true loop b[i] := i; end for;

In this case is the rhs not treated correctly and b is not assigned boolean values but the values 1 and 2 respectively, i.e. as its indices.

Real x[5]; algorithm for r in 1.0: 1.5: 5.5 loop x[integer(r)] := r; end for; x[3] := 3.0;

Similar case here where the right hand side gets the value of the index.

Boolean b[Boolean]; algorithm for i in Boolean loop b[i] := i; end for;

Is not accepted, warning "The expression of for index i must be a vector expression: Boolean has 0 dimension(s)" raised.

The same concept but for enums

type TwoEnums = enumeration( one, two); TwoEnums te[TwoEnums]; algorithm for e in TwoEnums loop te[e] := e; end for;

Same type of warning: "The expression of for index e must be a vector expression: TwoEnums has 0 dimension(s)"

### Change History (2)

### comment:1 Changed 3 years ago by

Description: | modified (diff) |
---|---|

Summary: | Handle different kinds of for boolean/enum loop constructions → Handle different kinds of for loop constructions |

### comment:2 Changed 21 months ago by

**Note:**See TracTickets for help on using tickets.

Also needs to handle strings.