New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variability of record instances #1832
Comments
Comment by hansolsson on 16 Dec 2015 09:19 UTC record Rec
constant Real x = 1;
constant Real y = 2;
end Rec;
function Func
input Rec r;
output Real z;
algorithm
z := r.x + r.y;
annotation (Inline=false);
end Func;
model Main
Rec rec; // Notice that rec is not declared constant.
constant Real K = Func(rec); // Here rec is used as if it were constant.
end Main; |
Comment by jmattsson on 16 Dec 2015 09:56 UTC There is a related issue: record Rec
Real x;
Real y;
end Rec;
model A
Rec r;
end A;
model B
A a(r = Rec(1, 2));
end B;
model Test
B b(a(r(x = 3)));
end Test; Is the modification in Test allowed? I think these issues are closely related, and should be resolved together. |
Comment by dietmarw on 8 Jan 2016 19:07 UTC |
Modified by stefanv on 3 Mar 2016 16:50 UTC |
Comment by hansolsson on 9 Mar 2016 14:34 UTC |
Modified by otter on 5 Aug 2016 05:58 UTC |
Comment by hansolsson on 13 Sep 2016 12:49 UTC
Should investigate if this is still the case - possibly in Spice3.
Unclear if "rec" should be seen as constant or not - depends on whether viewing "rec" as a collection of components, or as the whole record. |
Comment by hansolsson on 14 Sep 2016 12:49 UTC The most correct case seems to be require 'rec' to be declared as constant to treat it as constant (according to 3.8.1). |
Reported by stefanv on 11 Nov 2015 15:34 UTC
If all of the members of a record are declared constant or parameter, is an instance of the record itself automatically considered a constant or parameter, even if it is not explicitly declared as such?
Is the definition of
Main.K
legal? Its value depends onrec
, which is not declared as a constant.[Note that if the function were inlined, the resulting expression would be constant, and I could envision a tool failing to notice that
rec
itself is not constant. Hence, I added theInline=false
annotation toFunc
, although it shouldn't actually make a difference to the legality of the declaration ofK
.]Migrated-From: https://trac.modelica.org/Modelica/ticket/1832
The text was updated successfully, but these errors were encountered: