Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#3281 closed defect (fixed)

Error: Wrong number of subscripts in number[eqn2] (1 subscripts for 0 dimensions)

Reported by: Lennart Ochel Owned by: Per Östlund
Priority: high Milestone: 1.9.4
Component: MetaModelica Version: trunk
Keywords: Cc: Martin Sjölund

Description

It is often needed to use arrayGet in for loops to avoid strange errors if array elemts get accessed via iterator directly.

for eqn2 in mT[var] loop
  if number[eqn2] == -1 then
    [...]
  end if;
end for;

The snippet above generates following error Message:

Error: Wrong number of subscripts in number[eqn2] (1 subscripts for 0 dimensions).

This can be avoided if number[eqn2] get replaced by arrayGet(number, eqn2).

Change History (8)

comment:1 by Adrian Pop, 10 years ago

Owner: changed from Adrian Pop to Per Östlund
Status: newassigned

Per, can you have a quick look at this?

comment:2 by Lennart Ochel, 10 years ago

BTW: Is there a good reason that it is needed to use arrayUpdate instead of writing to an array element via squared bracket syntax?

in reply to:  2 comment:3 by Per Östlund, 10 years ago

Replying to lochel:

BTW: Is there a good reason that it is needed to use arrayUpdate instead of writing to an array element via squared bracket syntax?

No, there's no good reason for that. I'm trying to fix it, but the compiler does weird things with subscripted crefs.

comment:4 by Per Östlund, 10 years ago

Resolution: fixed
Status: assignedclosed

All right, fixed in r25678, both accessing and assigning arrays using the bracket syntax should work now. It turned out that someone had already implemented code generation for assignment to MetaModelica array crefs, but because of a typo it was never used.

comment:5 by Lennart Ochel, 10 years ago

Should it be possible to write to arrays using the bracket syntax that are inputs, since it is possible using arrayUpdate?

in reply to:  5 comment:6 by Per Östlund, 10 years ago

Replying to lochel:

Should it be possible to write to arrays using the bracket syntax that are inputs, since it is possible using arrayUpdate?

Yes, subscripted MetaModelica arrays are converted into the appropriate arrayUpdate/arrayGet calls in the code generation depending on which side of the assignment they are on.

comment:7 by Dietmar Winkler, 9 years ago

Milestone: Futurepre1.9.4

It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.

comment:8 by Martin Sjölund, 7 years ago

Milestone: pre1.9.41.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.