Opened 13 years ago
Last modified 9 years ago
#1628 new defect
Subscripting jagged arrays give errors
Reported by: | Martin Sjölund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | Version: | ||
Keywords: | Cc: | Martin Sjölund, Per Östlund |
Description
OpenModelica thinks n[2].r
has dimension 3. Works in Dymola:
model N parameter Integer n; Real r[n]; end N; model M N[2] n(n = {3,4}); equation n[1].r = {1,2,3}; n[2].r = {4,5,6,7}; end M;
Also try to fix:
model M N[2] n(n = {3,4}); equation n[:].r = {{1,2,3},{4,5,6}}; end M;
(It succeeds but should not!)
Change History (3)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Also, this one is fun (and not handled by Dymola):
model M N[2] n(n = {3,4}); N[2] m(n = {3,4}); equation n[1].r = {1,1,1}; n[2].r = {1,1,1,1}; n[:].r = 2*m[:].r; end M;
comment:3 by , 9 years ago
Milestone: | → Future |
---|
Note:
See TracTickets
for help on using tickets.
This doesn't really have anything to do with jagged arrays. It's a problem with our current environment, which doesn't handle arrays of complex components well. When we elaborate the equations we need to look up
n[1].r
orn[2].r
, but n is stored in the environment as a variable of array complex type. It then has it's own environment since it's complex, which contains n and r from N. We thus have only one instance of n.n and n.r in the environment, which for some reason isn[1].n
andn[1].r
. So the following model is also instantiated wrongly, giving bothj[1]
andj[2]
the value 3:This might be a bit tricky to fix.