Opened 7 years ago
Last modified 7 years ago
#4502 new defect
Comparison fails for enumerations wrapped in uniontypes
Reported by: | Per Östlund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | critical | Milestone: | Future |
Component: | MetaModelica | Version: | |
Keywords: | Cc: |
Description
See the attached script, which simply wraps an enumeration in a uniontype and then tries to compare it. The expected output is:
f: E.one f: E.two f: E.three
The actual output if no extra flags are given is:
f: f:
The bigger issue though is that when code generation is forced on with '-d=noevalfunc,gen', representing what happens if you try to do something like this in the compiler, the output becomes:
f: E.two f: f:
If the function is rewritten to use a match instead:
function f input UT ut; protected String s; algorithm print("f: "); s := match ut.e case E.one then "E.one"; case E.two then "E.two"; case E.three then "E.three"; end match; print(s + "\n"); end f;
then it behaves correctly when code generation is forced on but still gives the same output when using interpretation.
Attachments (1)
Change History (4)
by , 7 years ago
comment:1 by , 7 years ago
Priority: | high → critical |
---|
follow-up: 3 comment:2 by , 7 years ago
I actually get the expected behavior in my copy of OMC (and the nightly build). And... rewriting it using match seems to work as expected for you as well (because there is no function interpretation of match-expressions).
comment:3 by , 7 years ago
Replying to sjoelund.se:
I actually get the expected behavior in my copy of OMC (and the nightly build). And... rewriting it using match seems to work as expected for you as well (because there is no function interpretation of match-expressions).
I also get the correct behaviour when using code generation now, has something changed? I wouldn't close this ticket unless we're certain that this is actually fixed, considering that it gave undefined behaviour previously.
Bumping this up to critical, because I recently pushed in code that worked on one machine and passed the tests on Hudson, but which behaved erratically on another machine due to this issue.