Opened 14 years ago
Last modified 14 years ago
#1285 closed task (fixed)
Incorrect warning regarding missing 'inner' declaration.
Reported by: | dhedberg | Owned by: | dhedberg |
---|---|---|---|
Priority: | high | Milestone: | Red October |
Component: | Frontend | Version: | |
Keywords: | Cc: | dhedberg, adrpo |
Description
Consider the following definitions:
package A model C1 extends CBase; model S1 extends SBase; end S1; S1 s1; end C1; partial model CBase inner Real V=1; end CBase; partial model SBase outer Real V; end SBase; end A;
Checking the package the results in the following warning:
Warning: No corresponding 'inner' declaration found for component V declared as 'outer '. Please declare an 'inner' component with the same name in the top scope. Continuing flattening by only considering the 'outer' component declaration.
This warning should not be there, the matching inner declaration of V in SBase, is found in CBase which is inherited by C1.
This bug is a major bug as all SBML models when being translated to Modelica in MathModelica get this structure and hence this warning.
MathCore note: This ticket corresponds to ticket 2958 in MathModelica trac.
Change History (6)
comment:1 Changed 14 years ago by adrpo
comment:2 Changed 14 years ago by adrpo
Somewhere in the instantiation instVar is called with no prefix
Prefix.NOPRE while instantiating component s1 with type S1, so
I end up instantiating outer V with no prefix (top scope), which gives
this warning. Investigating it now.
comment:3 Changed 14 years ago by adrpo
Oh, the horror. The problem is that it tries to instantiate SBase as a class extending
basic types with Prefix.NOPRE() (top level) and it fails, but not before printing those
error messages. Getting rid of these error messages is not that easy as you still want
to print the errors regarding classes extending basic types.
At least now I know what the problem is, but I'll have to investigate more on how to fix it.
comment:4 Changed 14 years ago by adrpo
Fixed, see SCM Commits for more info.
comment:5 Changed 14 years ago by dhedberg
The problem is still there (to some extent). If I call getErrorString() after the a call to checkModel(A) I still get the same warning.
Warning: No corresponding 'inner' declaration found for component V declared as 'outer '. Please declare an 'inner' component with the same name in the top scope. Continuing flattening by only considering the 'outer' component declaration.
comment:6 Changed 14 years ago by adrpo
What is checkModel(A) supposed to do?? A is a package\\
If I run this script on OpenModelica:
loadFile("InnerOuter.mo"); getErrorString(); instantiateModel(A.C1); getErrorString(); checkModel(A.C1); getErrorString(); checkModel(A); getErrorString();
I get this:
adrpo@kafka ~/dev/OpenModelica/build/bin $ ./omc InnerOuter.mos true "" "class A.C1 Real V = 1.0; end A.C1; " "" "Check of A.C1 completed successfully. Class A.C1 has 1 equation(s) and 1 variable(s). 1 of these are trivial equation(s). " "" "Check of A completed successfully. Class A has 0 equation(s) and 0 variable(s). 0 of these are trivial equation(s). " ""
If i run this (checking of all models within package A)
loadFile("InnerOuter.mo"); getErrorString(); checkAllModelsRecursive(A); getErrorString();
I get this:
adrpo@kafka ~/dev/OpenModelica/build/bin $ ./omc InnerOuter.mos true "" Number of classes to check: 5 Checking skipped: package A... Checking: model A.C1... 0.0 seconds -> OK Check of A.C1 completed successfully. Class A.C1 has 1 equation(s) and 1 variable(s). 1 of these are trivial equation(s). Checking: model A.C1.S1... 0.0 seconds -> OK Check of A.C1.S1 completed successfully. Warning: No corresponding 'inner' declaration found for component V declared as 'outer '. Please declare an 'inner' component with the same name in the top scope. Continuing flattening by only considering the 'outer' component declaration. Class A.C1.S1 has 0 equation(s) and 1 variable(s). 0 of these are trivial equation(s). Checking: partial model A.CBase... 0.0 seconds -> OK Check of A.CBase completed successfully. Warning: Forcing full instantiation of partial class CBase during checkModel. Class A.CBase has 1 equation(s) and 1 variable(s). 1 of these are trivial equation(s). Checking: partial model A.SBase... 0.016 seconds -> OK Check of A.SBase completed successfully. Warning: Forcing full instantiation of partial class SBase during checkModel. Warning: No corresponding 'inner' declaration found for component V declared as 'outer '. Please declare an 'inner' component with the same name in the top scope. Continuing flattening by only considering the 'outer' component declaration. Class A.SBase has 0 equation(s) and 1 variable(s). 0 of these are trivial equation(s). "done" ""
BUT the warnings are *perfectly* normal in this case as we are instantiating
the classes without a context in which inner is present!
Issue verified.