Opened 6 years ago
Closed 6 years ago
#5479 closed defect (fixed)
OMC accepts invalid equations with conditional components
Reported by: | Francesco Casella | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: | Andrea Bartolini |
Description
Please check the following model:
model M parameter Boolean p = true; Real x; Real y if p; equation x= 10; if p then y = 20; end if; end M;
As far as I am concerned, I would be inclined to say that this model is valid. However, the Modelica Specification section 4.4.5 states explicitly
A component declared with a condition-attribute can only be modified and/or used in connections
So, as I understand, M
is not valid Modelica. However, both the OF and the NF accept this model and simulate it.
Change History (8)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
For the record, Dymola 2019 FD01 rejects the model in pedantic mode, but silently accepts it by default, so it is possible that there are Dymola-generated models around with this pattern. Not in the MSL, though, that is supposed to be checked with pedantic mode.
follow-up: 4 comment:3 by , 6 years ago
PR #3089 broke 33 models from 9 libraries, 27 of which were formerly happily verifying or simulating.
We could start a crusade with the library development to upgrade the code, but as long as the NF doesn't have problems with it, I would suggest that we just make this a warning and live with it for the time being.
follow-up: 7 comment:4 by , 6 years ago
Replying to casella:
We could start a crusade with the library development to upgrade the code, but as long as the NF doesn't have problems with it, I would suggest that we just make this a warning and live with it for the time being.
Yes, I plan on doing that, and maybe introduce a pedantic flag (we actually have one, but it's unused). But unfortunately Martin started to move the OMCompiler repository before I had time to make those changes, so I'm waiting for that to be finished.
follow-up: 6 comment:5 by , 6 years ago
@perost, isnt't the move already finished? I could make a PR and Jenkins ran it and then I merged it from the web interface.
comment:6 by , 6 years ago
Replying to adrpo:
@perost, isnt't the move already finished? I could make a PR and Jenkins ran it and then I merged it from the web interface.
I've been waiting for an update from Martin, but maybe he forgot to tell everyone that it was done.
comment:7 by , 6 years ago
Replying to perost:
I plan on doing that, and maybe introduce a pedantic flag (we actually have one, but it's unused).
To be honest, I don't like the word "pedantic" at all. It was introduced in Dymola several years ago, but I think it conveys the wrong message. Asking model developers to respect the Modelica semantics is not being pedantic, in fact, it's the only way to promote true interoperabilty among Modelica tools, which should be one of our strategic goals. See also the discussion in #2247.
I would propose to use "strict" instead.
comment:8 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed a while ago. The error was changed to a warning since it as expected broke some library models otherwise, and a --strict
flag was introduced that changes it back to an error.
Fixed in 273cbf8.
I made it a hard error though and expect it to break some models, so I will most likely change it later to just be a warning. But I made it an error for now to be able to catch any issues with the check, and to see what the impact on the libraries is.