#2779 closed defect (fixed)
Indexing with zero gives no error message
Reported by: | Peter Aronsson | Owned by: | Per Östlund |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.1 |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: |
Description
Consider this example.
model Experiment3 Modelica.Blocks.Sources.CombiTimeTable combiTimeTable2(fileName="foo.mat"); Modelica.Blocks.Math.Gain gain1(k=1); equation connect(gain1.u,combiTimeTable2.y[0]); end Experiment3;
This should give an error since it is not allowed to index with zero.
This was tested a long time ago on 1.8.1 and it did give an error message, but apparently not true anymore (tested on 1.9.1 beta2)
Change History (6)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
I agree that the case above could be checked during runtime. But the example in the report is indexing with zero in a connection set, and that -must- be checked by the frontend.
comment:4 by , 10 years ago
Well, it doesn't have to be checked in the front-end. The back-end could also catch the error in this case. But I agree it is nicer if errors are caught early.
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in r21937. I implemented some more error checking for array subscripts, and check index bounds in connects. There's many other places where it might be good to check index bounds too, but it's hard to know where it's safe to do so with how the compiler is currently structured.
Consider the following:
Dymola says that function is OK. So we need to allow it. We handle models in the same way...
Dymola does not like that model though, but since you need to handle the first case...
It makes sense to check these things in the backend or runtime. Since illegal expressions are sometimes allowed, we need to handle them in some way. Maybe by making the expression become DAE.FAIL(errorMessage) or something so the backend can produce the original error if branch selection chooses a bad branch (or the subscript is not used in a branch; something elabExp does not know about).