#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 , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
follow-up: 3 comment:2 by , 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?
comment:3 by , 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 , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.
follow-up: 6 comment:5 by , 10 years ago
Should it be possible to write to arrays using the bracket syntax that are inputs, since it is possible using arrayUpdate?
comment:6 by , 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 , 9 years ago
Milestone: | Future → pre1.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 , 7 years ago
Milestone: | pre1.9.4 → 1.9.4 |
---|
Removing the pre1.9.4 milestone in favor of 1.9.4.
Per, can you have a quick look at this?