Opened 7 years ago
Closed 7 years ago
#4383 closed defect (invalid)
Array constructor { } fails
Reported by: | jens.schoenbohm@… | Owned by: | sjoelund.se |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MetaModelica | Version: | |
Keywords: | array constructor | Cc: |
Description
Array construction with { } and constants fail. If I use { } and expressions everything is ok. See example
function main protected Real m[:]; Real b[:]; algorithm m := {1.0,2.0,3.0,4.0}; // Error: Type mismatch in assignment in m := List(#(1.0), #(2.0), #(3.0), #(4.0)) of Real[:] := list<#Real> b := {r for in 1.0:4.0}; // OK end main;
Change History (4)
comment:1 follow-up: ↓ 2 Changed 7 years ago by sjoelund.se
comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 7 years ago by lochel
Replying to sjoelund.se:
MetaModelica doesn't allow using Modelica-style arrays.
Is there any good reason for this restriction?
comment:3 in reply to: ↑ 2 Changed 7 years ago by sjoelund.se
Replying to lochel:
Replying to sjoelund.se:
MetaModelica doesn't allow using Modelica-style arrays.
Is there any good reason for this restriction?
Yes. It doesn't work very well to mix them. Modelica arrays are not boxed, sometimes stack-allocated, is mutable, and horrible with function pointers. So with -d=rml, {} becomes a list and you basically cannot use arrays.
Also remember, RML syntax for array<Real> was equivalent to Real[:], but they are totally different in OMC.
comment:4 Changed 7 years ago by lochel
- Resolution set to invalid
- Status changed from new to closed
MetaModelica doesn't allow using Modelica-style arrays.