Opened 16 years ago
Last modified 16 years ago
#1029 closed defect (fixed)
GenericMicroCircuit.mo should fail grammar
Reported by: | MichaelSpiegel | Owned by: | MichaelSpiegel |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | ||
Keywords: | Cc: | MichaelSpiegel, |
Description
The test case GenericMicroCircuit.mo has a declaration of the form:
class GenMicroCircuit2
replaceable type CompType = Resistor extends TwoPin;
replaceable CompType comp1;
end GenMicroCircuit2;
"replaceable type CompType" begins to match the element non-terminal, but then the class specifier uses the '=' form, which is not allowed an extends clause. I don't understand the specification well enough to state whether this declaration should be allowed in the specification. But either this declaration should be allowed (and the spec changes), or this should not be allowed (and the test case is marked as invalid).
Change History (3)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Aha. So just to clarify, this program isn't Modelica 3.0 compatible, but the OpenModelica compiler accepts this program in order to be backwards compatible with Modelica 2.2. That makes sense to me, thanks for the help.
comment:3 by , 16 years ago
Hi Michael,
Yes, we accept quite all Modelica versions.
In the future we might add a compiler flag
to turn off the backwards compatibility.
For example:
omc +grammar=Modelica3.0
Merry Christmas & Happy New Year!
Cheers,
Adrian Pop/
Hi,
This is not true. The "extends TwoPin"
part is matched by the constrain_clause.
See the Modelica Specifcation 2.2, page 10
at the bottom:
http://www.modelica.org/documents/ModelicaSpec22.pdf|http://www.modelica.org/documents/ModelicaSpec22.pdf
In Modelica Specification 3.0 the "extends TwoPin"
was replaced by "constrainedby TwoPin", but we also
kept the "extends TwoPin" for
backwards compatibility:
http://www.modelica.org/documents/ModelicaSpec30.pdf|http://www.modelica.org/documents/ModelicaSpec30.pdf
Cheers,
Adrian Pop/